I think this article best describes my problem:
The article indicates "When you write SQL queries, avoid enclosing the items listed in the SELECT clause in parentheses."
Could someone review this code to see if there is a better way to write this query so Access doesn't shut down everytime I run it? Code (abbreviated to remove error handling, etc.):
Dim ctl As Control
Dim varItem As Variant
Dim strSQL As String
Set ctl = Me.List34
strSQL = "Select * from Users where [UserName]="
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & "'" & ctl.ItemData(varItem) & "' OR [UserName]="
Next varItem
strSQL = Left$(strSQL, Len(strSQL) - 15)
CurrentDb.QueryDefs("usersquery2".SQL = strSQL
DoCmd.OpenReport "Users and Groups", acViewPreview, , , acDialog
End Select
THANKS very much for any help!!
tgikristi
The article indicates "When you write SQL queries, avoid enclosing the items listed in the SELECT clause in parentheses."
Could someone review this code to see if there is a better way to write this query so Access doesn't shut down everytime I run it? Code (abbreviated to remove error handling, etc.):
Dim ctl As Control
Dim varItem As Variant
Dim strSQL As String
Set ctl = Me.List34
strSQL = "Select * from Users where [UserName]="
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & "'" & ctl.ItemData(varItem) & "' OR [UserName]="
Next varItem
strSQL = Left$(strSQL, Len(strSQL) - 15)
CurrentDb.QueryDefs("usersquery2".SQL = strSQL
DoCmd.OpenReport "Users and Groups", acViewPreview, , , acDialog
End Select
THANKS very much for any help!!
tgikristi