Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Los Angeles

    Thumbs up Unanswered: help with .FindFirst code

    Hello, I have a form with the following textboxes, FirstName, LastName, EmployeeNo, Module. The following code is on my Before_Update event of the EmployeeNo textbox. (EmployeeNo is my primary key). What I'm trying to do, is prompt the user whenever there is an already existing record. Everything works except when the user clicks OK to go to the record it comes up with;

    Run-Time error 3077
    Syntax error (missing operator) in expression.
    Anyways here's the code;

    Dim varEmpNum As Variant

    varEmpNum = DLookup("FirstName", "Contacts", "Employee=""" & Me.Employee & """")
    If Not IsNull(varEmpNum) Then
    'the employee already exists
    If MsgBox("An Employee with this name already exists, would you like to go to this record?", vbYesNo) = vbYes Then
    'cancel update
    Cancel = True
    'undo the changes to this record
    'go to matching record
    With Me.RecordsetClone
    .FindFirst "Employee=" & Me.Employee
    If Not .NoMatch Then
    Me.Bookmark = .Bookmark
    End If
    End With
    End If
    End If

  2. #2
    Join Date
    Jan 2003
    Rockville, MD
    Use the same syntax to FindFirst, as you did to DLookup - all those extra double-quotes are needed.

    .FindFirst "Employee=""" & Me.Employee & """"

Posting Permissions

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