By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,530 Members | 891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,530 IT Pros & Developers. It's quick & easy.

Passing parameters to form and query

P: 22
Dear Fellows,

I m in in Access VB, and working on a small project.
Problem is that

In main form (called search )I have made a textbox name text34, and a search button, which responsiblity is to open a form.
I have made a query that show results which 'like Form.search.text34.text'.
when i execut this query by double clicking its ask me to enter value of Form.search.text34.text and show correct results.
On the same i made an other form base on that query. which also works fine when double click on that form on same principles as for query.

Now problem is that when I enter data through search form and press search it shows all the records and does not consider criteria entered.

If this cannot be achieved then please tell me any other way by which i can get the desired results.
i.e. pass parameter to query and then to form.
in my project execution sequence is
search button->form->query->selct date from text34

Plz help me. Thx
Oct 26 '06 #1
Share this Question
Share on Google+
3 Replies


pks00
Expert 100+
P: 280
Instead of

like Form.search.text34.text'

try this syntax

like Forms!Search!text34

if it dont have asterix in that textbox. try this

like "*" & Forms!Search!text34 & "*"


I recommend u rename your textbox from text34 to something more meaningful
Oct 26 '06 #2

MMcCarthy
Expert Mod 10K+
P: 14,534
[quote=Jahangir]

The standard way to open a form with criteria

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Name of form to be opened"
stLinkCriteria = "[FieldOnForm]=" & Me.[textboxName]

DoCmd.OpenForm stDocName, , , stLinkCriteria
Oct 27 '06 #3

pks00
Expert 100+
P: 280
Just to expand on mmccarthy's post (not taking credit though :-D)

For strings u need single quotes

stLinkCriteria = "[FieldOnForm]='" & Me.[textboxName] & "'"

for strings with single quotes in then use chr$(34)

stLinkCriteria = "[FieldOnForm]=" & chr$(34) & Me.[textboxName] & chr$(34)

and for dates the use #'

stLinkCriteria = "[FieldOnForm]=#" & Me.[textboxName] & "#"
Oct 27 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.