Change a field in a query with User Input?

Mel_P

Registered User.
Local time
Today, 15:09
Joined
Mar 13, 2009
Messages
11
I know that using parameters I can input a particular value of a field but is it possible to modify the field itself in a query using a variable or VBA say using a text box value?

I have a table with several fields each containing many rows:

sales.AI
sales.CG
sales.HF
etc. (18 similar fields)

In a select query I want to select:

Table1.Field A Table1. Field B (a particular but selectable field from sales) Table2.FieldA

I can do this by manually entering the field that I want, e.g. sales.AI BUT I want to be able to select (like a parameter) whether field sales.AI or sales.CG is used

I have tried this as a parameter (e.g. sales.[user input]) but that doesn't work OR as a variable (e.g. sales.variable where the variable is set in code) but that doesn't work! All I get is the text appearing in the field not the value of the field.

Any ideas please - I don't want to produce 18 different queries for each variation.

Thanks, Mel
 
What you want to do should be possible. I create QueryDefs on the fly using a form to allow the user to select what fields they want to see in the export. I use VBA code to generate the SQL and store it using the QueryDef collection.

without seeing your VBA code and SQL, it will be hard to spot any issues in your method.
 

Users who are viewing this thread

Back
Top Bottom