Hi
Can anyone tell me why I am getting this error message when applying the sql to a query please?
Here is my code:
[code=vb]
Private Sub cmdJobs_Click()
Dim cat As New ADOX.Catalog
Dim cmd As ADODB.Command
Dim varItem As Variant
Dim strArea As String
Dim strZone As String
Dim strStatus As String
Dim strSQL As String
Dim blnTest As Boolean
'sql statement
strSQL = "SELECT tblJobs.ClientN ame, tblJobs.ClientA ddress, tblJobs.ClientS uburb, Postcodes.Local ity, Postcodes.State , Postcodes.Pcode , tblJobs.ClientP hone, tblJobs.ClientM obile, tblJobs.Referre r, tblJobs.okayed, tblJobs.Notes, tblJobs.TeamAll ocated, tblJobs.Area, tblJobs.Zone, tblJobs.Rubbish Removal, tblJobs.Mower, tblJobs.UteTrai lor, tblJobs.TeamFoc us, tblJobs.Assista nt, tblJobs.Status, tblYWCDate.[YWC Date], tblJobs.JobsID, tbAreas.Colour, tblZones.ZColou r" & _
" FROM tblYWCDate, tbAreas INNER JOIN (tblZones INNER JOIN (tblJobs INNER JOIN Postcodes ON tblJobs.ClientS uburb = Postcodes.Local ity) ON tblZones.ZoneNa me = tblJobs.Zone) ON tbAreas.AreaNam e = tblJobs.Area;"
' Apply the SQL statement to the stored query
cat.ActiveConne ction = CurrentProject. Connection
Set cmd = cat.Views("qryJ obSheets").Comm and
cmd.CommandText = strSQL
Set cat.Views("qryJ obSheets").Comm and = cmd
Set cat = Nothing
[/code]
This is the line where the problem is showing up:
Set cat.Views("qryJ obSheets").Comm and = cmd
The sql was copied from the query itself and when I get past this problem I will be adding variables to change the sql via forms fields
I have used this code (not the sql obviously) in another database without problems and I have checked the references which are all the same except for Calendar which I doubt would be the issue.
Greg
Can anyone tell me why I am getting this error message when applying the sql to a query please?
Here is my code:
[code=vb]
Private Sub cmdJobs_Click()
Dim cat As New ADOX.Catalog
Dim cmd As ADODB.Command
Dim varItem As Variant
Dim strArea As String
Dim strZone As String
Dim strStatus As String
Dim strSQL As String
Dim blnTest As Boolean
'sql statement
strSQL = "SELECT tblJobs.ClientN ame, tblJobs.ClientA ddress, tblJobs.ClientS uburb, Postcodes.Local ity, Postcodes.State , Postcodes.Pcode , tblJobs.ClientP hone, tblJobs.ClientM obile, tblJobs.Referre r, tblJobs.okayed, tblJobs.Notes, tblJobs.TeamAll ocated, tblJobs.Area, tblJobs.Zone, tblJobs.Rubbish Removal, tblJobs.Mower, tblJobs.UteTrai lor, tblJobs.TeamFoc us, tblJobs.Assista nt, tblJobs.Status, tblYWCDate.[YWC Date], tblJobs.JobsID, tbAreas.Colour, tblZones.ZColou r" & _
" FROM tblYWCDate, tbAreas INNER JOIN (tblZones INNER JOIN (tblJobs INNER JOIN Postcodes ON tblJobs.ClientS uburb = Postcodes.Local ity) ON tblZones.ZoneNa me = tblJobs.Zone) ON tbAreas.AreaNam e = tblJobs.Area;"
' Apply the SQL statement to the stored query
cat.ActiveConne ction = CurrentProject. Connection
Set cmd = cat.Views("qryJ obSheets").Comm and
cmd.CommandText = strSQL
Set cat.Views("qryJ obSheets").Comm and = cmd
Set cat = Nothing
[/code]
This is the line where the problem is showing up:
Set cat.Views("qryJ obSheets").Comm and = cmd
The sql was copied from the query itself and when I get past this problem I will be adding variables to change the sql via forms fields
I have used this code (not the sql obviously) in another database without problems and I have checked the references which are all the same except for Calendar which I doubt would be the issue.
Greg
Comment