Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    79

    Unanswered: CHeck if field exists

    This seems so easy but I can't get it to work. I have a subform with invoice detail info. When user enters BOL field, I want to check if that BOL already exists. When I execute the following, I get data type mismatch error.

    Private Sub BOL_AfterUpdate()
    Dim rsLading As New ADODB.Recordset
    Dim SQLStmt As String
    SQLStmt = "Select * from tblInvoiceDtl where [BOL] = " & Forms![frmInvoice].[frmInvoiceDetail].[Form]![BOL]
    rsLading.Open SQLStmt, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
    If Not rsLading.EOF Then
    MsgBox "Bill of Lading has entered on another invoice." & Err.Description, vbCritical, "Warning"
    End If
    End Sub

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Well if BOL is text then you need to quote it ... Ex:

    ... ([BOL] = '" & Forms![frmInvoice].[frmInvoiceDetail].[Form]![BOL] & "');"
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Mar 2004
    Posts
    79
    See it was easy...just not for me! Thanks!

Posting Permissions

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