Creating default values based on prior inputs to a form

G

Guest

I'm having a table where I use a lookup combo box for the customer name in
the customers table. The next field in my form is the customer's
corresponding country field which can also be found in the customers table.
Hence, I want Access to choose this country as the default value BUT if that
is not the correct country for the specific transaction the user should
choose country from the countries table in an lookup combo box.

Greatful to answers / Bell
 
G

Guest

In the after update event of the customer name combo box simply set the
country field as below. If it is wrong you can drop the combo list and select
a different country.

[Country Field] = DLookUp("[Country Field]","Customers","[Customer] = '" &
[Customer Field] & "'")
 
G

Guest

Hi Dennis,
thanks for your reply. Im writing the following right next to the After
Update field in my customer combo box;

[Combo19]=DLookUp("[Country]", "Customers", "[Customer]=' " & [Combo21] &" '
")

Combo19 is hence my country combo box, country is the field I want to return
from the customers table, where customer should be equal to the value in
combo box. However I get the message that Access can't find the macro when.

Am I missing something?



"Dennis" skrev:
In the after update event of the customer name combo box simply set the
country field as below. If it is wrong you can drop the combo list and select
a different country.

[Country Field] = DLookUp("[Country Field]","Customers","[Customer] = '" &
[Customer Field] & "'")

Bell said:
I'm having a table where I use a lookup combo box for the customer name in
the customers table. The next field in my form is the customer's
corresponding country field which can also be found in the customers table.
Hence, I want Access to choose this country as the default value BUT if that
is not the correct country for the specific transaction the user should
choose country from the countries table in an lookup combo box.

Greatful to answers / Bell
 
G

Guest

This is VBA code and not a property value to put in the After Update event.
What I meant was select Event Procedure from the drop down list against the
'After Update' property of the combo box. Then click on the 3 elipses button
to to right and this will put you into VBA code. This is where you type in
what I gave you but remove the space behind the apostrophes.

[Combo19]=DLookUp("[Country]", "Customers", "[Customer]='" & [Combo21] & "'")

Bell said:
Hi Dennis,
thanks for your reply. Im writing the following right next to the After
Update field in my customer combo box;

[Combo19]=DLookUp("[Country]", "Customers", "[Customer]=' " & [Combo21] &" '
")

Combo19 is hence my country combo box, country is the field I want to return
from the customers table, where customer should be equal to the value in
combo box. However I get the message that Access can't find the macro when.

Am I missing something?



"Dennis" skrev:
In the after update event of the customer name combo box simply set the
country field as below. If it is wrong you can drop the combo list and select
a different country.

[Country Field] = DLookUp("[Country Field]","Customers","[Customer] = '" &
[Customer Field] & "'")

Bell said:
I'm having a table where I use a lookup combo box for the customer name in
the customers table. The next field in my form is the customer's
corresponding country field which can also be found in the customers table.
Hence, I want Access to choose this country as the default value BUT if that
is not the correct country for the specific transaction the user should
choose country from the countries table in an lookup combo box.

Greatful to answers / Bell
 
G

Guest

Thanks Dennis, now it works perfectly.

"Dennis" skrev:
This is VBA code and not a property value to put in the After Update event.
What I meant was select Event Procedure from the drop down list against the
'After Update' property of the combo box. Then click on the 3 elipses button
to to right and this will put you into VBA code. This is where you type in
what I gave you but remove the space behind the apostrophes.

[Combo19]=DLookUp("[Country]", "Customers", "[Customer]='" & [Combo21] & "'")

Bell said:
Hi Dennis,
thanks for your reply. Im writing the following right next to the After
Update field in my customer combo box;

[Combo19]=DLookUp("[Country]", "Customers", "[Customer]=' " & [Combo21] &" '
")

Combo19 is hence my country combo box, country is the field I want to return
from the customers table, where customer should be equal to the value in
combo box. However I get the message that Access can't find the macro when.

Am I missing something?



"Dennis" skrev:
In the after update event of the customer name combo box simply set the
country field as below. If it is wrong you can drop the combo list and select
a different country.

[Country Field] = DLookUp("[Country Field]","Customers","[Customer] = '" &
[Customer Field] & "'")

:

I'm having a table where I use a lookup combo box for the customer name in
the customers table. The next field in my form is the customer's
corresponding country field which can also be found in the customers table.
Hence, I want Access to choose this country as the default value BUT if that
is not the correct country for the specific transaction the user should
choose country from the countries table in an lookup combo box.

Greatful to answers / Bell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top