If then Statement with Set Focus to a SubForm

N

neenmarie

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?
 
P

Paul Johnson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top