Set value for function through form code

G

Guest

TIA...

Not sure where to post...

I found info from Access Query group that I could define function and then
use it as variable for query object criteria, so...

I set up a function in a module for my database

Function testjbl()
testjbl = variablename
End Function

I have a button on a form that on click

variablename=7

In a query I set criteria to testjbl()

the query runs but apparently the value is not passed to testjbl()

Any help??? Does it matter where the function code is, module form code??
How should I set the value for variablename so the function uses the value
in the query??

Thanks so much anyone!!

Joel
 
G

Guest

The variable and function should be in a stand-alone module (not a form
module).
Both have to be declared as Public.

Public variablename As DataType

Public Function testjbl()
testjbl = variablename
End Function

Substitue variablename and DataType accordingly.

Steve
 
G

Guest

Steve:

Thanks so much..it works!!

You and many people had their hand in this one...

Incredible...setting an existing queries criteria via code...it's great...

Thanks to all,

Joel
 
G

Guest

Steve:

Well, I ran into trouble when I tried various options, maybe you can help.

I have a text field with acct #'s to query. Accts > and < (I know it's
text) but have same # of digits.

Public varname as string

Then in form code:

varname= ">7 and <10" and I get an error about data mismatch

also tried varname= >7 and <10 and get error

Any help about syntax for text when numbers are used

Thanks so much,

Joel
 

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

Top