Null values and combo boxes--a problem

G

Guest

I'm a newby in need of assistance.

I'm creating a form based on a query which includes two table-based combo
boxes: one from an ID#[CityID], with a city name field [CityName] and city
population field [CityPopulation]; and the other from an ID#[CountyID],
county name [CountyName], and county populations [CountyPopulation]. I only
require that the form enter a value in ONE of the combo boxes. But, when I
enter data into the form without utilizing BOTH combo boxes, I get an error
message: for instance, if I only populate the 'CityID' query field with the
City combo box, I get an error message: "the MS Jet database engine cannot
find a record in the table 'tblCounties' with key matching field(s)
"CountyID'. However, if I complete BOTH combo boxes in the form--it records
everything just fine.

My question: How can I save my form completing only ONE of the CityID or
CountyID combo boxes while leaving null values in the fields produced by the
other/alaternate combo box (I have a subsequent field which utilizes the Nz()
function to look for the non Null value in one of the two fields I'm dealing
with here)?
 
M

Margaret Bartley

You'll have to create a dynamic query, since you don't know until the user
enters input if your query will be based on the city or the county.

To get the syntax for the queries, create the queries using the GUID for
queries, and look at the SQL view.

The AfterUpdate event of each combo boxes will create a different query:
the city combo box will create a query with the city as the parameter, and
the county combo box will create a query based on the county. Both queries
will have the same name, which will be the basis of your form.
 

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

Similar Threads

Combo boxes producing error message 3
Form help 4
dependent combo boxes 1
Cascading Combo Boxes 3
Combo Boxes/Queries 1
synchronized Combo Boxes in subforms 2
Combo Boxes 2
"Reset" combo boxes 4

Top