Query criteria from a form

T

Tom Hart

I want to use one query with a field (case ID) from either
one form or the other as the criteria to select upon. Is
there a way to set a variable or something so that the
query can reference the case ID field for whatever is the
active form?
 
M

Marshall Barton

Tom said:
I want to use one query with a field (case ID) from either
one form or the other as the criteria to select upon. Is
there a way to set a variable or something so that the
query can reference the case ID field for whatever is the
active form?


You can use Screen.ActiveForm!fieldname as a criteria, but
be careful, the active form isn't always what you might
think it is.
 
T

Tom Hart

Yes, this works for form1. Is there a way that I can use
the same query when I come from form1 or form2. I am
trying to avoid duplicating the query, forms and macros.

Thanks.
-----Original Message-----
Try

[Forms]![NameOfForm]![case ID]

Jim

-----Original Message-----
I want to use one query with a field (case ID) from either
one form or the other as the criteria to select upon. Is
there a way to set a variable or something so that the
query can reference the case ID field for whatever is the
active form?
.
.
 
R

Rod Scoullar

Tom

You could also declare a global variable, glngCaseID and set that to the
CaseID of the form in the Form_Activate event.

This way the last one of the forms you had active would provide the value to
the glngCaseID. You could then use this value as the criteria for the
query.

Rod Scoullar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top