The code below is for a search tool, but it returns an error if there isn't any data in the CompanyName field. To get around this I want to divert it to the LastName if there isnt anything in CompanyName.
I thought I could create a variable (CompLast) to use instead of using either CompanyName or LastName in the search tool.
Obviously this wasn't the way to go... what can I do?
I thought I could create a variable (CompLast) to use instead of using either CompanyName or LastName in the search tool.
Obviously this wasn't the way to go... what can I do?
Code:
Private Sub QuickSearch_AfterUpdate()
Dim CompLast As String
CompLast = [CompanyName]
If IsNull(Me![CompanyName]) Then
CompLast = Me![LastName]
End If
DoCmd.Requery
Me.RecordsetClone.FindFirst "CompLast = '" & Me![QuickSearch] & "'"
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
Else
MsgBox "Could not locate [" & Me![QuickSearch] & "]"
End If
End Sub