Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004

    Unanswered: DLookup Question

    Hi there!

    I have a quick question about DLookup..

    I have a form that I have setup to autofill depending on the customer chosen in a drop-down.

    I have the following tables:

    SalesEngineer(SalesID, SalesmanLast)
    Customer(CustomerID, CustomerName, CustomerBillto.... etc, SalesID)

    Where Customer.SalesID=SalesEngineer.SalesID)

    My form already pulls from some fields from the Customer table, but I would like it to display SalesmanLast.

    Is there any way to do this?

    Private Sub cbCustomer_AfterUpdate()
    On Error Resume Next

    If cbCustomer.Value > 0 Then
    Me.txtSales = DLookup("[Sales Engineer].[SalesmanLast]", "Customer, [Sales Engineer]", "[CustomerID]=" & cbCustomer.Value)
    Me.txtBillAddress = DLookup("[CustomerBillToAddress]", "Customer", "[CustomerID]=" & cbCustomer.Value)
    Me.txtBillCity = DLookup("[CustomerBillToCity]", "Customer", "[CustomerID]=" & cbCustomer.Value)
    Me.txtBillState = DLookup("[CustomerBillToState]", "Customer", "[CustomerID]=" & cbCustomer.Value)
    Me.txtBillZip = DLookup("[CustomerBillToZip]", "Customer", "[CustomerID]=" & cbCustomer.Value)
    Me.txtShipAddress = DLookup("[CustomerBillToAddress]", "Customer", "[CustomerID]=" & cbCustomer.Value)
    Me.txtShipCity = DLookup("[CustomerBillToCity]", "Customer", "[CustomerID]=" & cbCustomer.Value)
    Me.txtShipState = DLookup("[CustomerBillToState]", "Customer", "[CustomerID]=" & cbCustomer.Value)
    Me.txtShipZip = DLookup("[CustomerBillToZip]", "Customer", "[CustomerID]=" & cbCustomer.Value)
    Me.txtPrimaryPower = DLookup("[PrimaryPower]", "Customer", "[CustomerID]=" & cbCustomer.Value)
    Me.txtSecondaryPower = DLookup("[PrimaryPower]", "Customer", "[CustomerID]=" & cbCustomer.Value)

    End If

    End Sub

  2. #2
    Join Date
    Mar 2003
    The Bottom of The Barrel
    Provided Answers: 1
    Just out of curiousity... What is your main form bound to? Perhaps this would be better done with a subform.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

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