Using Parameter Queries ??

  • Thread starter Thread starter SpookiePower
  • Start date Start date
S

SpookiePower

I found this guide on the net -
http://www.fontstuff.com/access/acctut01.htm
and it works just fine for me, except that it show up
in a dialog box.

I now want to change it a bit, so it suits my needs better.
I want to put a bottom and a textbox on my form, so the
user can enter som text in the textbox, click the bottom
and the result is displayed in a subform.

As in the guide I have made a query in designview.
If I under the "critieria" types -
Like "*" & [type promt here] & "*" it will show up
in a dialogbox. I want to put the text from the textbox into
this search critiera.

My idea was to do it this way -
Like "*" & [Forms]![frmMain]![TextBoxSearchAdress] & "*"

But I can't get it to work.

Someone who can help ?
 
I tryed to change the criteria to this -

Like "*" & Me.TextBoxSearchAdress & "*"

but it still pops-up in a dialogbox.
 
I found this guide on the net -
http://www.fontstuff.com/access/acctut01.htm
and it works just fine for me, except that it show up
in a dialog box.

I now want to change it a bit, so it suits my needs better.
I want to put a bottom and a textbox on my form, so the
user can enter som text in the textbox, click the bottom
and the result is displayed in a subform.

As in the guide I have made a query in designview.
If I under the "critieria" types -
Like "*" & [type promt here] & "*" it will show up
in a dialogbox. I want to put the text from the textbox into
this search critiera.

My idea was to do it this way -
Like "*" & [Forms]![frmMain]![TextBoxSearchAdress] & "*"

But I can't get it to work.

Someone who can help ?

1) Your criteria is correct, assuming the field is a Text datatype.
2) The form "frmMain" must be open when the query is run. Is it?
3) What is the exact code behind the form's command button?
 
1) Your criteria is correct, assuming the field is a Text datatype.
Yes. It is text from a textbox
2) The form "frmMain" must be open when the query is run. Is it? Yes

3) What is the exact code behind the form's command button?

In my button I have this code in the On click event -

DoCmd.Requery "frmsubSøgAdresseContainer" (The name of the box holding my subform)

In my frmsubSøgAdresseContainer in the sourceobject property is
the name of the subform "frmsubSøgAdresse"

In the subform "frmsubSøgAdresse" I have in the sourcerecord property,
the name of the query.

The query looks like this.

SELECT taKunder.Kundenummer, taKunder.Firmanavn, taKunder.Adresse, taKunder.Byen, taKunder.Servicemaaned
FROM taKunder
WHERE (((taKunder.Adresse) Like "*" & Me.TextBoxSøgAdresse & "*"))
ORDER BY taKunder.Kundenummer;

My problem is that when I click the button, a dialog box pops up and ask me
to enter what I search for.

I don't want this dialogbox pop up. I want the the query to take what I search for
from the TextBoxSøgAdresse and not the dialogbox.
 
Yes. It is text from a textbox

I understand that it is a text box on your form, but the question was
"What is the datatype of the field (in the table, i.e. Number,
Date/Time, Text, Memo, Currency", etc.)
In my button I have this code in the On click event -

DoCmd.Requery "frmsubSøgAdresseContainer" (The name of the box holding my subform)

In my frmsubSøgAdresseContainer in the sourceobject property is
the name of the subform "frmsubSøgAdresse"

In the subform "frmsubSøgAdresse" I have in the sourcerecord property,
the name of the query.

The query looks like this.

SELECT taKunder.Kundenummer, taKunder.Firmanavn, taKunder.Adresse, taKunder.Byen, taKunder.Servicemaaned
FROM taKunder
WHERE (((taKunder.Adresse) Like "*" & Me.TextBoxSøgAdresse & "*"))
ORDER BY taKunder.Kundenummer;

My problem is that when I click the button, a dialog box pops up and ask me
to enter what I search for.

I don't want this dialogbox pop up. I want the the query to take what I search for
from the TextBoxSøgAdresse and not the dialogbox.

Me is a keyword that refers to the name of the object (form or report)
that it is placed in. It would be acceptable to use the Me word if you
have code placed in a form, i.e. Me![ControlName]

However, you have written it in a query, which does not recognize the
Me keyword.
You must use the full syntax of forms!FormName!ControlName.

in your where clause, it would be:

WHERE (((taKunder.Adresse) Like "*" &
forms!TheNameOfTheForm!TextBoxSøgAdresse & "*"))

If the NameOfTheForm is actually a sub-form you would need to use the
full path to the form and it's control:

Like "*" & Forms![main form name]![subform control name].Form![Control
Name] & "*"
 

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

Back
Top