Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Posts
    3

    Unanswered: Error trying to use DLookup

    Hi,

    When trying to use the below code to do a Dlookup using the value from the current combo box i.e. combo2 it throws a syntax error... please can someone help me fix it?

    Private Sub Combo2_AfterUpdate()
    ' Find the record that matches the control.

    If (DLookup("[CallID]", "tblCall", "[CallId] = " & Str(Me![Combo2]) Is Null) Then
    MsgBox "Please enter a valid Call ID", vbOKOnly, "Error"
    Else

    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[CallId] = " & Str(Me![Combo2])
    Me.Bookmark = rs.Bookmark
    End If
    End Sub

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    try:
    if isnull(DLookup("[CallID]", "tblCall", "[CallId] = '" & Str(Me![Combo2]) & "'")

    izy

  3. #3
    Join Date
    Oct 2003
    Posts
    3

    Unhappy

    Just did... but it throws a syntax error with "Private Sub Combo2_AfterUpdate()" highlighted in yellow.

    What I need to do is check wether the call ID entered really exists.... if it doesnt and DLookup returns a Null I need to throw that MsgBox with an error.

  4. #4
    Join Date
    Oct 2003
    Posts
    3
    Originally posted by izyrider
    try:
    if isnull(DLookup("[CallID]", "tblCall", "[CallId] = '" & Str(Me![Combo2]) & "'")

    izy
    Oh just noticed that the above had a missing ")"... However after fixing that it now throws this error "Data type mismatch in criteria expression"

Posting Permissions

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