Referening VBA in a Query

k209310

Registered User.
Local time
Today, 20:14
Joined
Aug 14, 2002
Messages
184
in a query it is possible to reference a forms text box using

forms!Form1Textbox1

is it at all possible to use a similar piece of SQL to reference a string in a VB module or would i have to put the entire piece of SQl in the VB and do it from there?

Cheers

Chris
 
To get around this I make sure the variable is present with a public declaration.

And in a module, let's say my public variable is a string (strMyName)

Code:
Public Function WhatIsMyName
   WhatIsMyName = strMyName
End Function

and in the criteria of the query, I'd put:

WhatIsMyName()
 
How do i do this if the string is assigned data during run time?
 
I don't know if you can use a runtime variable directly in the query but if you create the public variable then before running the query you can say

strYourPublicVariable = strYourRuntimeVariable

and that way the function will work with your runtime variable.
 
Doh!! How straghtforward was that (in hindsioght anyway) I should have known that. Thats about lesson four in VB School. - Sorry for wasting your time. Ive had a bad day today - Anyway Bring on the weekend

Cheers

Chris
 

Users who are viewing this thread

Back
Top Bottom