Query with Table and Column params.

JonnyToppa

New member
Local time
Yesterday, 23:42
Joined
Jan 25, 2012
Messages
5
Hello
I have a form in Access 2007 with a listbox of the Tables in a DB which displays the corresponding Columns in a listbox.
I wish to allow the user to make a Table selection from the listbox and a Column(s) selection from the second listbox, with a filter a see the result in datasheet view, ie SELECT @Columns FROM @Table WHERE @Column = @Filter.
Ive got the boxs set up ok on a form but cannot put the selected box values together to get the datasheet of the result. Do I need to use dynamic sql, with a recordset etc or querydef, or?
Thanks in advance.
 
if you mean by dynamic using vba then you got it right.

Code:
public function CreateDynQry(strcolumns as string, strTable as string, strWhere as string) as string
dim strSql as string

strSql = "SELECT " & strColumns & " FROM " & strTable & " WHERE " & strWhere

CreateDynQry = strsql

end sub

Share & Enjoy!

HTH:D
 
Last edited:

Users who are viewing this thread

Back
Top Bottom