Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modifying form selections in code then passing to query 3

Status
Not open for further replies.

monkeymagic2222

Technical User
May 13, 2002
78
0
0
GB
I've been tasked with modifying someones Access 2003 database.

I have a form with a bunch of comboboxes and a button that launches a query through its onclick event procedure. I can run this and pass the selected form values to the query without any problems. What I need to do is catch a couple of the selected form values, modify them depending on certain conditions and then pass the modified values to the query.

I've figured out how to grab and modify the selected form values in the onclick event but how do I then pass these to the query so that the query is taking it's parameters from both the form and the code?

Hope that makes sense!
 
I do not like to put form criterias directly in the query. I find it hard to write, test, and modify. So I wrap them in custom functions. Allows error checking, either to modify, and to do what you are asking.

Something like

Select .... where field1 = getField1() and field2 = getField2()


then in a public module

public function getField1() as variant
dim tempVal as variant
tempVal = nz(forms("someForm").someControl,0)
code here to do some modifications
getField1 = tempVal
end function

public function getField2() as variant
'no modification necessary just return the control value
getField2 = forms("someForm").someControl2
end function
 
Great thank you, that looks like a much cleaner way of doing what I want to achieve.
 
Nice, MajP! I'm going to swipe that technique for my bag of tricks. Have another star!

VBAjedi [swords]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top