Control Source of a Field

Little_Man22

Registered User.
Local time
Today, 03:35
Joined
Jun 23, 2001
Messages
118
Hi,

I have a form with a bunch of cells. These cells are currently unbound. I need them to be linked to a table through a querystring though...

What I want to happen, is for each cell to have some sort of query string that looks through the main table (Tickets) and performs a query based on specified information:

i.e. SELECT FROM Tickets WHERE Venue="Holiday Inn" AND Class=Adult/Senior"

If I just create a regular query like this it returns about 10 values (rows) for the given information above. In the end, I want the cell to just count the rows (i.e. give me an output of "10" for 10 records matching the above criteria). How do I do this and link it to the cell on the form?

Thanks,
-Ryan.
 
check help for the DCount Function.

al
 
Thanks pcs...worked perfectly. I have another question though.

Right now I have a form that I can input information into and it also updates a 'table' on the same form with a bunch of fields that are updated with control sources similar to the following:

=DCount("[Ticket]","Tickets","[Site] = 'Ambassador Hotel' And [Event] = 'Regular Daily Programing' And [Ticket] = 'Adult/Senior'")

I want to have a button on the form that, when pressed, will bring up a report. I've already created this report, however, it uses static DCount function similar to the one above. What I want to happen is that when someone presses the 'Report' button on the form it brings up a little box where they can enter a date. Once they've entered this date they can press the submit button and a report will appear that uses the date they just entered as part of the Control Source property on all of the fields listed (similar to the one below):

=DCount("[Ticket]","2","[Site] = 'Ambassador Hotel' And [Event] = 'Regular Daily Programing' And [Ticket] = 'Adult/Senior' And [Date] = 'DATE FROM FORM'")

How do I do this?

Thanks again,
-Ryan.
 
ryan

-----you wrote-----
I've already created this report, however, it uses static DCount function similar to the one above.
-------------------

not sure what you mean by 'static DCount'...
think you might want to post more info, as i think your db design might need some work.

there are a bunch of ways to do what you seek...

for starters, check help for the OpenReport method...

from help-----
DoCmd.OpenReport reportname[, view][, filtername][, wherecondition]

(wherecondition: a string expression that's a valid SQL WHERE clause without the word WHERE.)
--------------

this allows you to open a report with some SQL that limits the report data. the syntax for the wherecondition can get a little tricky, and i don't recall using it with domain aggr. functions (like DCount), but probably worth a try.

you could create an unbound textbox on your form for the date entry and disable the Print Report button until a date has been entered.

as i said, there a a bunch of ways to do this...

hth,
al
 
Last edited:

Users who are viewing this thread

Back
Top Bottom