B
Beetle
A bit of background to start.
A2003, split, multi-user. I have a form that uses a stored query as it's
recordsource. The query (qryDeliveries) pulls a limited number of records
from the table (the previous 7 days worth). In the header of the form are
unbound controls that are used for searching. When the users do a search
they need to be able to search the entire table, so in the click event of
the Search command button, I change the form's recordsource to a
SQL statement that is built from what they select in the unbound controls.
That part works perfectly. The part that seems like it should be the easiest
is giving me headaches. I have a Reset command buuton on the form
where I am attempting to change the form's recorsource back to the
original stored query. I can't seem to get Access to recognize the stored
query. I get a message that says "The recordsource you specified for this
form doesn't exist". I believe I need to use QueryDefs for this, but I must be
missing something. What I am currently attempting is;
Dim qdf As QueryDef
Set qdf = Currentdb.QueryDefs ("qryDeliveries")
Me.Recordsource = "qdf"
qdf.Close
Set qdf = Nothing
I've tried a few minor variations of the above with no luck. Maybe I'm wrong
about using QueryDefs for this in the first place. Just for grins I tried
setting
the recordsource to the query name directly, even though I didn't think it
would work, which it didn't. I'm a little stumped (nothing new <g>). Feel
free to point out if I'm just being an idiot
A2003, split, multi-user. I have a form that uses a stored query as it's
recordsource. The query (qryDeliveries) pulls a limited number of records
from the table (the previous 7 days worth). In the header of the form are
unbound controls that are used for searching. When the users do a search
they need to be able to search the entire table, so in the click event of
the Search command button, I change the form's recordsource to a
SQL statement that is built from what they select in the unbound controls.
That part works perfectly. The part that seems like it should be the easiest
is giving me headaches. I have a Reset command buuton on the form
where I am attempting to change the form's recorsource back to the
original stored query. I can't seem to get Access to recognize the stored
query. I get a message that says "The recordsource you specified for this
form doesn't exist". I believe I need to use QueryDefs for this, but I must be
missing something. What I am currently attempting is;
Dim qdf As QueryDef
Set qdf = Currentdb.QueryDefs ("qryDeliveries")
Me.Recordsource = "qdf"
qdf.Close
Set qdf = Nothing
I've tried a few minor variations of the above with no luck. Maybe I'm wrong
about using QueryDefs for this in the first place. Just for grins I tried
setting
the recordsource to the query name directly, even though I didn't think it
would work, which it didn't. I'm a little stumped (nothing new <g>). Feel
free to point out if I'm just being an idiot