Linking Combo box with query

akhlaq768

Registered User.
Local time
Today, 12:46
Joined
Jan 17, 2008
Messages
42
I am designing a form in Access…

I have a query already set up in the background that appends data from table_1 to table_2…. Using the month and year criteria….

How do I create a form that allows the user to select the appropriate month and click on the execute button – which alters the query in the background and runs it?

What I have already created is a table called “Date_Selection” Which holds a list months in a year. How do I link that to the query? For example, the user will select “February” and execute…. Hopefully the month selected will populate the criteria in the query and run it….

Many thanks
 

Attachments

Last edited:
How do I create a form that allows the user to select the appropriate month and click on the execute button – which alters the query in the background and runs it?
Because you are getting dynamic criteria instead of "set" criteria from an actual query, you will have to concatenate the values that are retrieved from your form. I would just use an executable command in VB, like so:
Code:
MyButton_Click()

currentdb.execute "INSERT INTO trend_analysis ( [Therapy service], [Month], 
[Year], SumOfTotalAttendances, SumOftotalDNAs, SumOfTotalCancellations )

SELECT therapy_final_table_0708.[Therapy service], 
   therapy_final_table_0708.Month, therapy_final_table_0708.Year, 
      Sum(therapy_final_table_0708.TotalAttendances) AS SumOfTotalAttendances, 
      Sum(therapy_final_table_0708.totalDNAs) AS SumOftotalDNAs, 
         Sum(therapy_final_table_0708.TotalCancellations) AS SumOfTotalCancellations

FROM therapy_final_table_0708

GROUP BY therapy_final_table_0708.[Therapy service], 
therapy_final_table_0708.Month, therapy_final_table_0708.Year

HAVING (((therapy_final_table_0708.Month) = [COLOR="Red"]" & me.combo13 & "[/COLOR] AND 
   ((therapy_final_table_0708.Year) = "2007/2008"));
The above code is based on the sample DB you provided.
 
thanks mate:)
 

Users who are viewing this thread

Back
Top Bottom