Unwanted loop in a Query on a subform

  • Thread starter Thread starter RoMi
  • Start date Start date
R

RoMi

My Query selects the records upon a parameter that must be entered by a
user. (Ex. Criteria= Like [Enter the number of days]). This works O.K. if
the data are shown in a Datasheet View.



But for some reason I need this Datasheet on a Sub Form of the Form called
frmOldData. This form is activated by a cmdButton on the Menu Form in this
way: cmdButton activate a macro which opens the frmOldData. Before the
frmOldData is opened a small window asks for the parameter for a query.
After the entering a requested number the same window appears again and I
have to repeat the same parameter again. After that the frmOldData opens
with a requested Datasheet on a Sub Form. All the data are correct.



Why the Query request the parameter two times? Where could be mistake?



All this is made in Access2002 using VBA.



Thank you for any advice.
 
Don't use a parameter query. Replace the parameter with a reference to a
control on a form.
 
Duane Hookom said:
Don't use a parameter query. Replace the parameter with a reference to a
control on a form.

Is it a rule, more pleasent way to control a query or just a way to avoid
theproblems?
 
It's my rule but not necessarily anyone else's. I would never use a
parameter query. If they work well for you in specific situations then
continue to use them.
 
Don't use a parameter query. Replace the parameter with a reference to a
control on a form.

--
Duane Hookom
MS Access MVP



RoMi

It's my rule but not necessarily anyone else's. I would never use a
parameter query. If they work well for you in specific situations then
continue to use them.

--
Duane Hookom
Microsoft Access MVP


I do not like parameter query, too but I use it because I have not enough
experience in Access and have no idea how to avoid it. What do you mean with
"Replace the parameter with a reference to a control on a form"? Should I
activate query by a cmdButton after the main form is already opened? In that
case a sub form (required for a Datasheet made by a query) stays empty until
the query doesn't start. I believe that you have ment some other
possibilities. What I need is that an user have to choose a 'parameter' and
direct a query what to do. Please, help me in few more words where to go?

Thanks for your time

M. Kadija
 
You can add unbound controls on your main form that are used to filter your
query. It may help to set the default value of the controls. Then set the
criteria of the query to something like
Between Forms!frmMain!txtStart and Forms!frmMain!txtEnd
 
O.K. I'll try to find out the control object that satisfies me best. I'd
like that the users may choose and select the criteria themselves without
typing any character.

Thanks.

M. Kadija
 
Back
Top