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

xytras

New member
Local time
Today, 03:09
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
 

KenHigg

Registered User
Local time
Today, 06:09
Joined
Jun 9, 2004
Messages
13,327
Set RS = DB.OpenRecordset(myQueryName, dbOpenForwardOnly)

???
 

pdx_man

Just trying to help
Local time
Today, 03:09
Joined
Jan 23, 2001
Messages
1,347
Set RS = DB.OpenRecordset("myQueryName", dbOpenForwardOnly)
 

Users who are viewing this thread

Top Bottom