Query criteria from a form

  • Thread starter Thread starter Tom Hart
  • Start date Start date
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?
 
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.
 
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?
.
.
 
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
 
Back
Top