Results 1 to 2 of 2
  1. #1
    pmac is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    12

    ComboBox after update/reload

    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
    Last edited by RuralGuy; 11-10-2011 at 11:56 AM. Reason: Added Code Tags

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    String variables can't be set to Null so if cboClientLookup is passing null to the sub then it will error. Determine why null is passing. What are the circumstances when null is passed? Is user starting to make entry then hits ESC key? Modify code to handle null input.

    Don't know what could be wrong with the subsequent line. Is ClientID a number datatype?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-03-2011, 11:56 PM
  2. Replies: 6
    Last Post: 07-28-2011, 04:07 AM
  3. Replies: 9
    Last Post: 12-18-2010, 12:51 PM
  4. How can I reload data on a form?
    By MrC in forum Forms
    Replies: 2
    Last Post: 07-21-2010, 02:58 AM
  5. ComboBox to update picture
    By ron727 in forum Programming
    Replies: 2
    Last Post: 05-21-2009, 06:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums