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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |