»
 

Go Back   ResellerRatings Store Ratings > ResellerRatings Forums > Tech Support

Reply
 
LinkBack Thread Tools Display Modes
Old 11-23-2003, 04:59 PM   #1 (permalink)
Registered User
 
NoLimit's Avatar
 
Join Date: Apr 2001
Location: Northern California, USA
Posts: 55
NoLimit is on a distinguished road
MS Access: Passing values from a form to a parameter query

I'm trying to pass values entered from textboxes in a form to a parameter query. The problem I'm having is that when I try to run the query from the the form, it asks me to enter in values for the parameters instead of taking the values entered in the textboxes. I don't know what I'm doing wrong...

NoLimit is offline   Reply With Quote
Old 11-24-2003, 08:58 PM   #2 (permalink)
Registered User
 
Join Date: Nov 2001
Posts: 170
Turnip12 is on a distinguished road
How are you trying to do it? I'm new to Access myself, so I'm sure someone else could give you a better answer. but one way might be to open up your form in design view, bring up the properties for the form(right click in the gray box in the top left hand corner of your form) set your query as the control source. Then go to each text box, bring up the properties, and set the control source to the matching field in the query.
Turnip12 is offline   Reply With Quote
Old 11-24-2003, 10:28 PM   #3 (permalink)
Registered User
 
Join Date: Sep 2002
Posts: 265
Creosote is on a distinguished road
Edit the parameter query. If you have a form named Form2, and a TextBox name Text1 that has your parameter value, put the query crieteria like this:

[Forms]![Form2]![Text1]
Creosote is offline   Reply With Quote
Old 11-25-2003, 04:22 PM   #4 (permalink)
Registered User
 
NoLimit's Avatar
 
Join Date: Apr 2001
Location: Northern California, USA
Posts: 55
NoLimit is on a distinguished road
Excellent. The form's working almost fine. There's just one more small detail. One of the paramters I have in the query is option and is supposed to return all records if nothing is entered, but when I use the form and don't enter anything for that paramter nothing is shown.. I already have the paramter set to "... OR [forms]![form2]![text1] IS Null. When I run the query byself, it works as it should.
NoLimit is offline   Reply With Quote
Old 11-26-2003, 06:45 AM   #5 (permalink)
Registered User
 
Join Date: Oct 2001
Location: New Hampshire, USA
Posts: 604
ctaylor is on a distinguished road
Have a command button on the form to press after setting criteria in text boxes. the command box could call a test to check for empty parameters before running that will test to see if values are incomplete. You could either use the null test to call a message box and then exit sub, or you could try to autocomplete the values

The command button can run a test such as

if [Forms]![frmSearchCriteria]![txtStartDate].value is null and if [Forms]![frmSearchCriteria]![txtEndDate].value is not null then

msgbox "You must set a start date to run this report."
exit sub

Elseif [Forms]![frmSearchCriteria]![txtStartDate].value is not null and [Forms]![frmSearchCriteria]![txtEndDate].value is null then

msgbox "You must set a end date to run this report."
exit sub

Elseif [Forms]![frmSearchCriteria]![txtStartDate].value is null and [Forms]![frmSearchCriteria]![txtEndDate].value is null then

msgbox "You must set a start date and end date to run this report."
exit sub

Elseif [Forms]![frmSearchCriteria]![txtStartDate].value is not null and [Forms]![frmSearchCriteria]![txtEndDate].value is not null then

docmd.openreport "rptStartDate_EndDate_Report"

end if
ctaylor is offline   Reply With Quote
Old 12-15-2003, 03:12 PM   #6 (permalink)
Registered User
 
Join Date: Dec 2003
Posts: 1
Brass is on a distinguished road
Outdoors Spanish

Just thought I'd add a little something to this thread in the hope that perhaps it will save someone all the wasted time I spent trying to solve my problem...

I was having a similar problem accessing form controls for use in parameter queries. I couldn't for the life of me figure out what I was doing wrong. I was using the Expression Generator and it would still puke (Access kept asking me for a value for these parameters). After a lot of head scratching I finally noticed that the expression generator was giving me "[Formularios]![Form2]![Text1]" I'm working in Costa Rica and so using a Spanish version of Access 2002. For some reason, the expression generator seems to be talking Spanish but Access is still talking English. Argh!!! So once I changed the expression to "[Forms]![Form2]![Text1]" all was well.
Brass is offline   Reply With Quote
Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Most Active Discussions

Recent Discussions

All times are GMT -6. The time now is 03:10 AM.