If then Statement with Set Focus to a SubForm

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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
 
Back
Top