Hi
I taught myself access a few years ago so I'm not only rusty but don't really understand what I'm doing. I mostly blunder along until I figure out how to do something. Also, I'm very poor at getting a question across, so I'm going to break this one up and start really simple.
I am trying to use a function as criteria in a query. The function has a parameter that is a variable and the query is the recordsource for a form
I declared the variable in a standard module, at the top as:
Public strTitle as String
and in the same module defined the function, as:
Function Title(strTitle as String) as String
Title = strTitle
End Function
Then, as the query criteria I am trying to put Title(strtitle) and Access insists on putting quotes around strTitle and it returns nothing. I am assigning a value to strTitle in VBA and then opening the form with DoCmd.OpenForm
If I define the function as
Function Title()
Title = strtitle
End Function
It works, but I don't remember it working like that and don't want to run into trouble further down the line when I plan on using that function as a Form's Title.
Hope that makes sense and thanks in advance for any help or advice.
A/R
I taught myself access a few years ago so I'm not only rusty but don't really understand what I'm doing. I mostly blunder along until I figure out how to do something. Also, I'm very poor at getting a question across, so I'm going to break this one up and start really simple.
I am trying to use a function as criteria in a query. The function has a parameter that is a variable and the query is the recordsource for a form
I declared the variable in a standard module, at the top as:
Public strTitle as String
and in the same module defined the function, as:
Function Title(strTitle as String) as String
Title = strTitle
End Function
Then, as the query criteria I am trying to put Title(strtitle) and Access insists on putting quotes around strTitle and it returns nothing. I am assigning a value to strTitle in VBA and then opening the form with DoCmd.OpenForm
If I define the function as
Function Title()
Title = strtitle
End Function
It works, but I don't remember it working like that and don't want to run into trouble further down the line when I plan on using that function as a Form's Title.
Hope that makes sense and thanks in advance for any help or advice.
A/R