Check if field exists

jason_nevin

Registered User.
Local time
Today, 12:34
Joined
Nov 22, 2002
Messages
46
I have a query which has a form field name as part of its criteria. There are two forms which access this query from their onload event (its a delete query). I would like to vary the field name in the query dependant on which form is executing the query.

i.e If form 1 runs the query I want to use field [Forms]![Form1]![Field] and if form 2 [Forms]![Form2]![Field]. Any ideas.

Thanks.
 
Jason,

Your query needs to be consistent.

1) Use a QueryDef and dynamically create the query using the
proper value (Form1 or Form2).

2) Use a Public Function to return the value. The function
can check for Form1 or Form2.

Wayne
 
Thanks Wayne. I was hoping to avoid doing either of those because;

1. If I have to change the query in the future it means changing the code rather than editing the query in the query generator which is inconsistent with the rest of the database.

2. I didn't really want to write a function just for this because it seemed to be a bit untidy. I was rather hoping that there might be an IIF statement which I could use.

I wrote a simple public function in the end and it works fine.

Thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom