How to use query(given by name) in module funktion?

xytras

New member
Local time
Today, 02:43
Joined
Oct 5, 2005
Messages
9
Hi
I how such code:

Public Function fConList()
Dim DB As DAO.Database
Dim RS As DAO.Recordset

Dim strSQL As String
Dim strText As String

strSQL = "SELECT Contact.To FROM Contact" '
Set DB = CurrentDb

'Open a Recordset and loop through it to fill the text box txtTest

Set RS = DB.OpenRecordset(strSQL, dbOpenForwardOnly)

How to put some other query given by name to instead of putting sql directly into string?
I have also textfield that has this =fConList() as source.
Is it possible that i will have some combo box or list of queries and one button. When i press this button the name of the query in the function will change to the chosen One from the list.
Any Ideas?
i'm beginner so,
Thanks in Advance for some examples
 
Set RS = DB.OpenRecordset(myQueryName, dbOpenForwardOnly)

???
 
Set RS = DB.OpenRecordset("myQueryName", dbOpenForwardOnly)
 

Users who are viewing this thread

Back
Top Bottom