Simple query with criteria dependent on current form value

T

TravelingHT

Just to let you know, if anyone is still with me, the Row Source for the
combobox is QryCustomerName Not sure if this makes any difference.

Yours truly.

Traveling HT


TravelingHT said:
Dear John:

The Control Name "CustomerID" relates to a combobox in the form
frmlTrips(spellingCorrect). So I am not trying to reference a control in an
underlying table. I hope that is what you where asking.

I am considering sending the valule of the result of the combobox to a
label, using code, making it non visable and referencing that in my query.

Currently the combobox named CustomerID references the tlbCustomer and binds
column 1 (CustomerID) but displays column 2&3, first and last names.

Thanks for your help.

Traveling HT


Now
--
Anthony Williams
Histotech Exchange LLC
19 Whitmore St.
Lexington, VA 24450
(e-mail address removed)



John W. Vinson said:
OK all this is not yet over but I think we are close.

So here is what I have done.

1. Put this code in the frmlTrips (spelling correct)

Option Compare Database
Option Explicit

PrivateSub CustomerID_AfterUpdate()
Me.frmVisit.Form!frmPetsAtVisit.Form!PetID.Requery

End Sub

2. I have a query in the form frmPetsAtVisit.

tblPets.PetID, tblPets.CustomerID, tblPets.PetsName

The query populates the drop down list with all of the pets owned by all of
the customers.

At this point when I open up the form frmlTrips I get no error messages I
can change the name of the person at will but I get every animal owned by
every customer all the time.

3. If I add to the criteria line, and I use the expression builder to do it;
[forms]![frmlTrips]![CustomerID]

I get the message both when I open the query and the form frmlTrips
"Enter Paramater Value" "Forms!frmlTrips!CustomerID"

And I do not get this message unless I put that code into the criteria line
of the customerID colum of the query.

Do you in fact have a CONTROL - not a field, but a combo box or textbox - on
frmlTrips named "CustomerID"?

If not, you'll get this error. It's looking for a control which does not
exist.

If CustomerID is just a fieldname in the form's recordsource, it's not
available for this query. What you can do is create a textbox on the form
(named CustomerID or, better, txtCustomerID), bound to the field, and use that
control's name in the query criteria. Set the textbox's Visible property to No
since you probably want to conceal the (autonumber??) ID from the user.
 

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