You didn't specify whether you're using ADO, DAO, etc., or what type of
recordset you're using -- a data control or just a defined recordset.
Here's an example using ADO and a defined recordset to retrieve a row from
the table Tasks, and the decoded user name from table D_UserName
corresponding to the D_UserName foreign key (owner_user_name) stored in the
Tasks record. I'll assume you've already established the connection object
(aCn):
Dim lRecordset As Recordset
Dim lsSQL As String
Dim ls_pk_task As String
lsSQL = _
"SELECT *, user_name " & _
"FROM Tasks " & _
"INNER JOIN D_UserName" & _
" ON Tasks.owner_user_name = D_UserName.pk_username " & _
"WHERE pk_task = " & ls_pk_task & " "
Set lRecordset = New ADODB.Recordset
lRecordset.Open lsSQL, aCn, adOpenDynamic, adLockOptimistic, adCmdText
Pete
-----Original Message-----
From: Raju S.Pusapati [mailto:rajupusapati@y...]
Sent: Tuesday, November 19, 2002 8:44 PM
To: professional vb
Subject: [pro_vb] Linking multiple variables to create dynamic sql
statements
Hi,
I am working on a project which needs to link various selected variables
(two or more)from two or more tables to find matched records.The user
selects the required variables(columns names) of each table from the list
box. I tried with selecting two or more variables from multi-select list
boxes of two different tables, to pass the variables to construct the sql
statement.But the sql statement not taking the selected variables from the
list boxes, and fails to link the selected variables.
Please let me know if there will be any other approach to try to link
multiple variables to retrieve the records,
Thanks,
Raju