Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating a combo Box from a field

Status
Not open for further replies.

Chippie

Programmer
Oct 5, 2001
11
GB
I am trying to populate a combo box (Region/County) using an entered field (country). I have to use the country field in the WHERE clause to obtain the correct results set from the SQL query. I know I need to rip the data from the form, and have tried using VBa as so.

Form_Customer.Country.Requery

As an event in the AfterUpdate field.

The query look like so

SELECT DISTINCT Country.[Name], Country.[Cty], [Region Codes].[Description] FROM [Region Codes], Country WHERE [Region Codes].[Country] = Country.[Cty] AND [Region Codes].[Country] = forms![Customer]![Country].Value;

can anyone help me with this...
 
try this

Combo1.RowSource = "SELECT DISTINCT Country.[Name], Country.[Cty], [Region Codes].[Description] FROM [Region Codes], Country WHERE [Region Codes].[Country] = Country.[Cty] AND [Region Codes].[Country] = " & Forms![Customer]![Country].Value & ";"
Combo1.Requery
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Where do I actually put this. I have entered the code, but I get a prompt asking me for

Forms!Customer!Country.Value

All I want to do is rip it from the screen, and place the country code in a SQL query.

Also if I do enter the code in the prompt it doesn't update the box on each record. How do I do this ?? If I get the other query to work.
 
If you select the relvant control in form-design view, one of the options is row-source (assuming it is a combo or listbox). You then simply construct a query to return the correct data...... James Goodman
j.goodman00@btinternet.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top