Jeff.Nolan
12-10-2007, 12:14 PM
Here is the code I have:
Private Sub CmbGenerate_Click()
Dim MyDB As DAO.Database
Dim qdef As DAO.QueryDef
Dim i As Integer
Dim strWhere As String
Dim strIN As String
Dim varItem As Variant
Set MyDB = CurrentDb()
'Build the IN string by looping through the listbox
For i = 0 To lstENTITYNAME.ListCount - 1
If lstENTITYNAME.Selected(i) Then
strIN = strIN & "'" & lstENTITYNAME.Column(0, i) & "',"
End If
Next i
'Create the WHERE string, and strip off the last comma of the IN string
strWhere = "in (" & Left(strIN, Len(strIN) - 1) & ")"
Set qdef = MyDB.QueryDefs![MainQuery]
qdef.Parameters![ENTITY SETS]![ENTITY SET NAME] = strWhere
DoCmd.OpenQuery "MainQuery", acViewNormal
End Sub
The problem I am having is with these 2 lines.
Set qdef = MyDB.QueryDefs![MainQuery]
qdef.Parameters![ENTITY SETS]![ENTITY SET NAME] = strWhere
I am trying to get the info from strWhere to be sent to a query I have called "MainQuery" in the criteria field ENTITY SET NAME, which is from the table ENTITY SETS
Any help would be great.
Thanks so much.
Private Sub CmbGenerate_Click()
Dim MyDB As DAO.Database
Dim qdef As DAO.QueryDef
Dim i As Integer
Dim strWhere As String
Dim strIN As String
Dim varItem As Variant
Set MyDB = CurrentDb()
'Build the IN string by looping through the listbox
For i = 0 To lstENTITYNAME.ListCount - 1
If lstENTITYNAME.Selected(i) Then
strIN = strIN & "'" & lstENTITYNAME.Column(0, i) & "',"
End If
Next i
'Create the WHERE string, and strip off the last comma of the IN string
strWhere = "in (" & Left(strIN, Len(strIN) - 1) & ")"
Set qdef = MyDB.QueryDefs![MainQuery]
qdef.Parameters![ENTITY SETS]![ENTITY SET NAME] = strWhere
DoCmd.OpenQuery "MainQuery", acViewNormal
End Sub
The problem I am having is with these 2 lines.
Set qdef = MyDB.QueryDefs![MainQuery]
qdef.Parameters![ENTITY SETS]![ENTITY SET NAME] = strWhere
I am trying to get the info from strWhere to be sent to a query I have called "MainQuery" in the criteria field ENTITY SET NAME, which is from the table ENTITY SETS
Any help would be great.
Thanks so much.