OutputTo with variable

hbrems

has no clue...
Local time
Today, 14:21
Joined
Nov 2, 2006
Messages
181
Dear all,

I have a query which I would like to export to excel. I have created a form with a combobox for this. When I click the export button the following code is triggered:

Code:
DoCmd.OutputTo acOutputQuery, "qryuserlist", acFormatXLS, "H:\", True

The issue I have is that the query accepts a variable 'system'. The combobox on my form holds this variable.

Question: how do I pass the variable from the combobox into the query...

Once again I rely on your kind help to sort this out...

Kind regards,
Hans B.
 
You can do it the nice and easy way and reference the control on the form:

In the criteria put: [forms]![Form_Name_Here]![Combo_Box_Name_Here]

Then close the form . . .


OR if you really want to populate the variable System:
1. Rename it strSystem
2. On the On_Click event of the combox box assign the Public Variable strSystem to combo box value.
3. Write a public function that returns the value of strSystem.
4. In Query call the function.
 
You can do it the nice and easy way and reference the control on the form.

I went for this option, works like a charm and is simple too.

Thanks man!
 

Users who are viewing this thread

Back
Top Bottom