473,385 Members | 1,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Method 'Command' of object 'view' failed

31
Hi

Can anyone tell me why I am getting this error message when applying the sql to a query please?

Here is my code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdJobs_Click()
  2.     Dim cat As New ADOX.Catalog
  3.     Dim cmd As ADODB.Command
  4.     Dim varItem As Variant
  5.     Dim strArea As String
  6.     Dim strZone As String
  7.     Dim strStatus As String
  8.     Dim strSQL As String
  9.     Dim blnTest As Boolean
  10.  
  11. 'sql statement
  12. strSQL = "SELECT tblJobs.ClientName, tblJobs.ClientAddress, tblJobs.ClientSuburb, Postcodes.Locality, Postcodes.State, Postcodes.Pcode, tblJobs.ClientPhone, tblJobs.ClientMobile, tblJobs.Referrer, tblJobs.okayed, tblJobs.Notes, tblJobs.TeamAllocated, tblJobs.Area, tblJobs.Zone, tblJobs.RubbishRemoval, tblJobs.Mower, tblJobs.UteTrailor, tblJobs.TeamFocus, tblJobs.Assistant, tblJobs.Status, tblYWCDate.[YWC Date], tblJobs.JobsID, tbAreas.Colour, tblZones.ZColour" & _
  13. " FROM tblYWCDate, tbAreas INNER JOIN (tblZones INNER JOIN (tblJobs INNER JOIN Postcodes ON tblJobs.ClientSuburb = Postcodes.Locality) ON tblZones.ZoneName = tblJobs.Zone) ON tbAreas.AreaName = tblJobs.Area;"
  14.  
  15.  
  16.  ' Apply the SQL statement to the stored query
  17.         cat.ActiveConnection = CurrentProject.Connection
  18.         Set cmd = cat.Views("qryJobSheets").Command
  19.         cmd.CommandText = strSQL
  20.         Set cat.Views("qryJobSheets").Command = cmd
  21.         Set cat = Nothing
  22.  
This is the line where the problem is showing up:
Set cat.Views("qryJobSheets").Command = 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
Feb 14 '08 #1
2 1619
Stewart Ross
2,545 Expert Mod 2GB
This is the line where the problem is showing up:
Set cat.Views("qryJobSheets").Command = 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
Greg
Hi Greg. Looks like there could be a problem with the SQL statement, not the code. I tested by substituting SQL and table references for one of my test tables without any difficulties - in line with what you say about having used this code before yourself.

Your SQL statement seems fine as far as can be seen without the table defs to refer to, and anyway you copied it directly from a query. Is the Areas table correctly prefixed tbAreas (and not tblAreas) throughout?

-Stewart
Feb 19 '08 #2
OzNet
31
Thanks Stewart for your reply.

I have found a work around without actually resolving the problem head on.

Google searches seem to indicate a problem of compatibility with the ADOX dll's I tried following some of the instructions but didn't really know what I was doing.

There seems to be issues with Vista and Access 2003 but it was not working on my laptop with XP either.

Eventually (today) I changed from ADOX to DAO and it works fine.

Thanks again Stewart for taking the time to find a resolution.
Feb 21 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: shank | last post by:
Can anyone give me some general ideas on why an error like Object doesn't support this property or method: 'ZoneRS.MoveFirst' comes up on a page? MoveFirst is a command to move to the first...
2
by: Mike Button | last post by:
Hello all, I am really really desperate on what I should do, and I am asking for help from anyone in this newsgroup, here's the situation: I am creating a form that is being run on a server...
0
by: John Phelan | last post by:
I have created a front-end application and back-end database. Everytime that I opened the program in the past, it open just fine with no errors when linking to the back-end tables. lately, I get...
0
by: John Phelan Cummings | last post by:
I have created a front-end application and back-end database. Everytime that I opened the program in the past, it open just fine with no errors when linking to the back-end tables. Lately, I...
2
by: Todd | last post by:
This has really been my day for wierd problems sorting one of my forms (a subform actually)... so here's another one. I am now receiving the following error Run-time error '-2146500594...
2
by: Reginald Bal | last post by:
Hello, I created a main form with 2 subforms. In an attempt to move to the next record (or new record) on the main form I get the error " Method 'requery' of object '_Subform' failed". The...
12
by: | last post by:
Is it fine to call another method from Switch? Eg. Switch (stringVar) { case ("a"): somVar = "whatever"; Another_Method(); //call another method return;
8
by: Gary | last post by:
I'm using an Act database. I was stuck on this a year ago and am still having trouble. I have three bits of code like so : - act.CActAppObj objACT = new act.CActAppObj(); act.CAIBaseView...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.