Search code examples
vbams-accessms-access-forms

How to see name when I enter an id in access form


I have a Form where I Enter CustomerID in a combo box. This box has Two Columns CustomerID and CustName.

the CustName and CustFather reside in another query.

is there a way to show the CustName and CustFather everytime i enter CustomerID in the form?

The CustomerID is entered in a form and not in the same table as CustName and CustFather.

Tried DLookup but it just looks only the first time and then shows that same value everytime i open the form or update it. the dlookup is shown as:

=DLookUp("CustName","qryForRecovery","CustomerID =" & "CustomerID")

is there a way i can show the CustName everytime i update the CustomerID field?

This is the link to the snapshot of my recovery form. https://i.sstatic.net/YzuxK.png


Solution

  • Use a combo box to enter the customerId.
    Then create a text box for the customerName, that links to the customerId combo, as explained here.
    The trick is to properly set the properties of the combo:
    RowSource Type: Table/Query
    Source: SELECT CustomerID, CompanyName FROM tblCustomers
    Bound column: 1
    Column count: 2
    Limit to List: Yes
    Column widths: 3;0 'second column will be hidden