JHMarshIII
Registered User.
- Local time
- Today, 11:47
- Joined
- Feb 8, 2002
- Messages
- 19
Iv'e got a form that uses a key (UnitKey) to look up the record if the key is found. If found I want the focus to move to a particular control, if not found I want the focus to move to another inquiry control. I think my code is wrong when I try to test the result for the If/Then statement. Here is the code:
Private Sub UnitKeyAddr_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[UnitAddr] = '" & Me![UnitKeyAddr] & "'"
Me.Bookmark = rs.Bookmark
'Tests bookmark for hit
If IsNull(Me![UnitKeyAddr]) Then
' Clears UnitKey
Let Me![UnitKeyAddr] = ""
' Changes Focus to alphalookup
DoCmd.GoToControl "alphalookup"
Else
' Clears UnitKey
Let Me![UnitKeyAddr] = ""
' Changes Focus to Salutation
DoCmd.GoToControl "Salut"
End If
End Sub
In both a true and false case the focus is set to "Salut" so I think I am asking the wrong question in the line:
If IsNull(Me![UnitKeyAddr]) Then
Private Sub UnitKeyAddr_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[UnitAddr] = '" & Me![UnitKeyAddr] & "'"
Me.Bookmark = rs.Bookmark
'Tests bookmark for hit
If IsNull(Me![UnitKeyAddr]) Then
' Clears UnitKey
Let Me![UnitKeyAddr] = ""
' Changes Focus to alphalookup
DoCmd.GoToControl "alphalookup"
Else
' Clears UnitKey
Let Me![UnitKeyAddr] = ""
' Changes Focus to Salutation
DoCmd.GoToControl "Salut"
End If
End Sub
In both a true and false case the focus is set to "Salut" so I think I am asking the wrong question in the line:
If IsNull(Me![UnitKeyAddr]) Then