Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass Combo Box Value to Text Box and then Run multiple queries

Status
Not open for further replies.

e777akerson

Technical User
Mar 3, 2003
9
0
0
US
I have never tried this before and it may be a lot simpler than it appears. I want to make a combo box on a Form called MakeMonthSelect. I want the combo box selected value to populate five text boxes which won't be visible. The value in these five text boxes would be the criteria in the MonthName field for five crosstab queries. Can I then make a macro to run all five crosstab queries in a row thereby having them use the original combo box selected value for the criteria?
The suggested code used to populate the text boxes is:

Private Sub cboNames_AfterUpdate()
Me.txtFirstCTQry1=Me!cboNames.value
Me.txtFirstCTQry2=Me!cboNames.value
Me.txtFirstCTQry3=Me!cboNames.value
and so on
End Sub


Will this work or is there an easier way with minimal coding?

Eric Akerson
 
Hi,

I think that you can make a macro to run all 5 queries in a row. However, IMHO, macros tend to run a little slower and open up your DB to various problems (such as letting unauthorized people gain access to and run various procedures in Windows OS). Alternatively you might try the DoCmd.RunSQL statement (See Access VBA help for more info) -then you can pass the value directly to the sql statement without macros or copying to other fields first!

Ex: (this example inserts records into a table)

DoCmd.RunSQL "INSERT INTO Table1 (Value1) VALUES (YourTextBoxName);"

HTH,

jbehrne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top