Results 1 to 3 of 3

Thread: Access VB script problem

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    London, UK
    Posts
    39

    Red face Access VB script problem

    I am trying to perform a procedure which checks whether a customer in a table already exists by comparing First, Last Name and Post Code. Unfortunatly I have a probelm in the FirstName variable. This is what I have tried:

    Private Sub txtPCode_AfterUpdate()

    Dim FirstName As String
    Dim LastName As String
    Dim PCodeID As String
    Dim LCustomerID As String
    Dim FCustomerID As String

    FistName = ""
    LastName = ""
    LCustomerID = ""
    FCustomerID = ""
    PCodeID = ""

    LastName = DLookup("LName", "CustomerInfo", "LName = Forms![Add_Customer]![txtLName]")
    LCustomerID = DLookup("CustID", "CustomerInfo", "[CustomerInfo]![LName] = Forms![Add_Customer]![txtLName]")

    FirstName = DLookup("FName", "CustomerInfo", "[CustomerInfo]![CustID] = LCustomerID")

    FCustomerID = DLookup("CustID", "CustomerInfo", "[CustomerInfo]![CustID] = LCustomerID")

    PCode = DLookup("CustID", "CustomerInfo", "[CustomerInfo]![PCode] = Forms![Add_Customer]![txtPCode]")

    If ((IsNull(FirstName) And IsNull(LastName) = False) And (FCustomerID = LCustomerID = PCodeID)) Then
    MsgBox (FirstName + " " + LastName + " is an existing Customer, CustID = " + CustomerID)
    Forms![Add_Customer]![txtFName] = ""
    Forms![Add_Customer]![txtLName] = ""

    End If

    End Sub

    But this did not work So I tried this: (Everything else same apart from

    FirstName = DLookup("FName", "CustomerInfo", "[CustomerInfo]![CustID] =(DLookup("CustID", "CustomerInfo", "[CustomerInfo]![LName] = Forms![Add_Customer]![txtLName]"))")



    Can anyone help me with this problem? I will be very greatful

  2. #2

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    London, UK
    Posts
    39
    hmm tough one

  3. #3
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

Posting Permissions

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



Click Here to Expand Forum to Full Width