Running a query using data from a form

B

Brian C

I have a form called SINGLE BOOKING AVAILABILITY with
three input field called Date, Combo8 and Combo10 and a
command button.

I want to put the values from these fields into a SQL
statement attached to the command button, i.e.

SELECT AVAILABILITY.DATE, AVAILABILITY.PERIOD,
AVAILABILITY.ROOM, AVAILABILITY.BOOKING ID
FROM AVAILABILITY
WHERE (((AVAILABILITY.DATE)=date from form) AND
(AVAILABILITY.PERIOD)=combo8 from form) AND
(AVAILABILITY.ROOM)=combo10 from form));

How do I do this? How do I get the data out of the form
and into my query?

Thanks in advance.
 
J

John Vinson

I have a form called SINGLE BOOKING AVAILABILITY with
three input field called Date, Combo8 and Combo10 and a
command button.

I want to put the values from these fields into a SQL
statement attached to the command button, i.e.

SELECT AVAILABILITY.DATE, AVAILABILITY.PERIOD,
AVAILABILITY.ROOM, AVAILABILITY.BOOKING ID
FROM AVAILABILITY
WHERE (((AVAILABILITY.DATE)=date from form) AND
(AVAILABILITY.PERIOD)=combo8 from form) AND
(AVAILABILITY.ROOM)=combo10 from form));

How do I do this? How do I get the data out of the form
and into my query?

Thanks in advance.

Use

=Forms![SINGLE BOOKING AVAILABILITY]![Date]

etc. as the criteria.

Suggestion: Date is a reserved word, and Access *WILL* get confused;
and when you look at this form in six months, Combo8 will mean
absolutely nothing and you'll have to reverse-engineer your own code
to figure out what it's for. I'd suggest a textbox txtDate and combo
boxes named cboPeriod and cboRoom - but do change the Name properties
of these controls!
 

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