I've been trying to work through errors in this code in my database(Access 2007) and can't seem to find them. When I select a different record from the combobox I get a messagebox error (which I added to help find the problem). Here's the code:
Code:
Function ReloadClientLookup(sClientLookup As String)
Dim sNewStub As String ' First chars of ClientLookup.Text
On Error GoTo ErrMsg
If Not lockClientLookup Then
sNewStub = Nz(Left(sClientLookup, conClientLookupMin), "")
' If first n chars are the same as previously, do nothing.
If sNewStub <> sClientLookupStub Then
If Len(sNewStub) < conClientLookupMin Then
'Remove the RowSource
cboClientLookup.RowSource = "SELECT dbo_ClientInfo.clientID, dbo_ClientInfo.[lastName] & "", "" & [firstName] AS fullName FROM dbo_ClientInfo " _
& " WHERE dbo_ClientInfo.lastName = ""false"" "
sClientLookupStub = ""
Else
'New RowSource
cboClientLookup.RowSource = "SELECT dbo_ClientInfo.clientID, dbo_ClientInfo.[lastName] & "", "" & [firstName] AS fullName FROM dbo_ClientInfo " _
& " WHERE dbo_ClientInfo.lastName Like """ & sNewStub & "*"" " _
& " ORDER BY dbo_ClientInfo.lastName, dbo_ClientInfo.firstName;"
sClientLookupStub = sNewStub
End If
End If
End If
ErrMsg:
MsgBox ("Error")
End Function
I've also gotten an error in the afterupdate() method(when I debug sometimes it says "invalid use of null" on clientName = cboClientLookup, and sometimes an error on the line below that:
Code:
Private Sub cboClientLookup_AfterUpdate()
Dim clientName As String
lockClientLookup = True
clientName = cboClientLookup
DoCmd.SearchForRecord acActiveDataObject, , acFirst, "[clientID] = " & Str(Nz(Screen.ActiveControl, 0))
showAddressDetail (False)
showEventDetail (False)
Refresh
cboClientLookup.SetFocus
cboClientLookup = clientName
lockClientLookup = False
End Sub