Andrew wrote:
What happens is the list box chooses a client name, and the subform
enters services for that client. There are many services to one
client. The update query basically checks a box in the data to
'discharge' the client, so they won't show up in the list box anymore.
This button is clicked only after services have been entered and the
client leaves the program. I had the button on the main form, but got
the same result.
As far as writing a where clause, I don't know what to set the where
equal to.
Since the listbox identifies the client, you should include its value in
the query. I suggest you create a parameter in the query, and fill it
from code; I found that safest, maybe others disagree.
(( The other way is to put a reference to the listbox in the query's
WHERE (the criteria line in design view): forms!yourform!yourlistbox ))
To have a parameter in a query, enter a name within [sqare brackets] in
the Criteria line (and make sure it is a name that is not equal to one
of the fields in the query). Access will now ask a value for this name
when you open the query.
To fill the parameter from code, use this:
dim qd as querydef
set qd=currentdb.querydefs("thatQuery")
qd.parameters(0) = me!listboxname.value
qd.execute
set qd=nothing
I assume two things here: (1) there is only one parameter in the query,
and (2) the listbox is on the form with this code. Not in a subform or
superform.
--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea