Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2003
    Posts
    300

    Exclamation Unanswered: Error In Find Code

    Hello,

    I hope someone can help with this problem...

    I have a form that lists a customer table. I created a "find record" - unbound control that will allow the user to type in the first letter of the person and it will bring up that record.

    The problem is if that person is NOT in the table, the user gets an error that a NULL is not allowed.. and then they get another error

    RUN TIME Error 94

    Invalid use of Null

    Following is the code behind the Form,,

    Private Sub Combo224_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[Cust ID] = " & Str(Me![Combo224])
    Me.Bookmark = rs.Bookmark
    End Sub


    Any idea as to what I can do to take care of this problem???

  2. #2
    Join Date
    Nov 2003
    Posts
    300
    Can some one give me some HELP??

  3. #3
    Join Date
    Nov 2003
    Posts
    1,487
    Try this:
    Code:
    Private Sub Combo224_AfterUpdate()
       'Find the record that matches the control.
       Dim rs As Object
    
       Set rs = Me.Recordset.Clone
       On Error Resume Next
       rs.FindFirst "[Cust ID] = '" & Str(Me![Combo224]) & "'"
       If Err = 94 Then
          MsgBox"Customer Does Not Exist"
          Goto Exit_Combo224
       End If
       Me.Bookmark = rs.Bookmark
    
    Exit_Combo224:
       rs.Close
    End Sub

  4. #4
    Join Date
    Nov 2003
    Posts
    300

    Thumbs up

    Thanks!
    That worked great!

  5. #5
    Join Date
    Nov 2003
    Posts
    300

    Unhappy

    Well, I spoke too soon, it almost works,

    it handles the error correctly, but when an existing record is selected, it does not do the job that it was supposed to do, which is FIND the record...

    How do I do that now? Where do I make the change???

  6. #6
    Join Date
    Nov 2003
    Posts
    1,487
    Try this:
    Code:
    Private Sub Combo224_AfterUpdate()
       'Find the record that matches the control.
       Dim rs As Object
    
       Set rs = Me.Recordset.Clone
       On Error Resume Next
       rs.FindFirst "[Cust ID] = '" & Str(Me![Combo224]) & "'"
       If Err Then Goto Exit_Combo224
       Me.Bookmark = rs.Bookmark
    
    Exit_Combo224:
       rs.Close
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •