R
roccogrand
Would someone please tell me why this code is not working. I have tried all
the combinations that I can think of, as indicated by the remarks.
I get an 3075 error, no data, and no form with the code I think should work.
Thanks a million.
LDN
Private Sub cmdOpenMaster1_Click()
Dim MyQueryCode As String
Dim stDocName As String
Dim strSQL As Variant
stDocName = "frmMaster1"
MyQueryCode = Me.QueryCode
Select Case MyQueryCode
Case Is = 1312
'strSQL = "SELECT * FROM tblTasks WHERE ((tblTasks.Company) = ALL)"
strSQL = "SELECT * FROM tblTasks "
strSQL = strSQL & "WHERE [Company] = ALL"
strSQL = strSQL & "ORDER BY tblTasks.DueDate;"
'strSQL = strSQL & "ORDER BY tblTasks.DueDate"
'Doesn't work without the semicolon either
Debug.Print MyQueryCode
'My coded value from the previous form looks OK = 1312
Debug.Print strSQL
'The query looks OK'
'DoCmd.OpenForm stDocName
'Works but not filter or data
DoCmd.OpenForm stDocName, , , strSQL
'This is what I want to work
'DoCmd.RunSQL strSQL
'DoCmd.OpenQuery "qryTasksCompanyALL"
'These don't work
DoCmd.Requery
the combinations that I can think of, as indicated by the remarks.
I get an 3075 error, no data, and no form with the code I think should work.
Thanks a million.
LDN
Private Sub cmdOpenMaster1_Click()
Dim MyQueryCode As String
Dim stDocName As String
Dim strSQL As Variant
stDocName = "frmMaster1"
MyQueryCode = Me.QueryCode
Select Case MyQueryCode
Case Is = 1312
'strSQL = "SELECT * FROM tblTasks WHERE ((tblTasks.Company) = ALL)"
strSQL = "SELECT * FROM tblTasks "
strSQL = strSQL & "WHERE [Company] = ALL"
strSQL = strSQL & "ORDER BY tblTasks.DueDate;"
'strSQL = strSQL & "ORDER BY tblTasks.DueDate"
'Doesn't work without the semicolon either
Debug.Print MyQueryCode
'My coded value from the previous form looks OK = 1312
Debug.Print strSQL
'The query looks OK'
'DoCmd.OpenForm stDocName
'Works but not filter or data
DoCmd.OpenForm stDocName, , , strSQL
'This is what I want to work
'DoCmd.RunSQL strSQL
'DoCmd.OpenQuery "qryTasksCompanyALL"
'These don't work
DoCmd.Requery