A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

If then Statement with Set Focus to a SubForm



 
 
Thread Tools Display Modes
  #1  
Old August 24th, 2004, 09:43 PM
neenmarie
external usenet poster
 
Posts: n/a
Default If then Statement with Set Focus to a SubForm

Ken just helped me work through setting focus to a control on a subform. I'd
like to add an if/then statement to go to a new record if upon LostFocus a
control = 0 and if it doesn't equal 0 go to the subform to complete data
entry there. It seems this should work something like below

Iif([ScrappedPcs] = 0, (DoCmd.GoToRecord , , acnewrec),
(Me.SubForm.SetFocus) (Me.Subform!Control.SetFocus))

Am I even close?

  #2  
Old August 25th, 2004, 11:51 AM
Paul Johnson
external usenet poster
 
Posts: n/a
Default

The conditional IF statement IIF() is used to return a value, not execute
code blocks. You need to use a regular IF..THEN format to handle execution
of code.

If ScrappedPcs = 0 Then
DoCmd.GoToRecord, , acNewRec
Else
Me.Subform.Control.SetFocus
End If

"neenmarie" wrote in message
...
Ken just helped me work through setting focus to a control on a subform.

I'd
like to add an if/then statement to go to a new record if upon LostFocus a
control = 0 and if it doesn't equal 0 go to the subform to complete data
entry there. It seems this should work something like below

Iif([ScrappedPcs] = 0, (DoCmd.GoToRecord , , acnewrec),
(Me.SubForm.SetFocus) (Me.Subform!Control.SetFocus))

Am I even close?



  #3  
Old August 25th, 2004, 02:11 PM
neenmarie
external usenet poster
 
Posts: n/a
Default

Thank you for your help. I had to add one other line of code to set focus to
the subform first and then a line to set focus to the control on the subform.


If [ScrappedPcs] = 0 Then
[Operator].SetFocus
DoCmd.GoToRecord , , acNewRec

Else
Me.ScrapForm.SetFocus
Me.ScrapTransForm!PartNumber.SetFocus

Now it works perfecly thanks again.

Janine

"Paul Johnson" wrote:

The conditional IF statement IIF() is used to return a value, not execute
code blocks. You need to use a regular IF..THEN format to handle execution
of code.

If ScrappedPcs = 0 Then
DoCmd.GoToRecord, , acNewRec
Else
Me.Subform.Control.SetFocus
End If

"neenmarie" wrote in message
...
Ken just helped me work through setting focus to a control on a subform.

I'd
like to add an if/then statement to go to a new record if upon LostFocus a
control = 0 and if it doesn't equal 0 go to the subform to complete data
entry there. It seems this should work something like below

Iif([ScrappedPcs] = 0, (DoCmd.GoToRecord , , acnewrec),
(Me.SubForm.SetFocus) (Me.Subform!Control.SetFocus))

Am I even close?




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting focus to a control on a subform on opening John S. Ford, MD New Users 3 July 14th, 2004 06:36 AM
Setting focus to a control on a subform on opening John S. Ford, MD Using Forms 3 July 14th, 2004 06:36 AM
Setting focus to a control on a subform on opening John S. Ford, MD General Discussion 6 July 14th, 2004 06:36 AM
Using BeforeUpdate Event to set the focus onto the subform Joe Joplin Using Forms 1 June 27th, 2004 11:31 PM


All times are GMT +1. The time now is 12:02 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.