Re: Determining EVERY month between 2 given dates
- From: "Bob Barrows" <reb01501@xxxxxxxxxxxxxxx>
- Date: Mon, 17 May 2010 22:47:42 -0400
Edwinah63 wrote:
Thanks for your reply. I am having trouble now with the Create View
Statement.
To check I had the right syntax I created a dummy table with 1 field,
1 record. I then created the sample statement in the SQL view of both
an ordinary and so called "Data Definition" query
create view MyView as select dummyid from tblDummy
Both come back with the error "Syntax error in Create Table statement"
What am I doing wrong?
Had a google around and it seems that Access 2007 will not recognize
create view statement for this database unless the ANSI92
compatibility is turned on and the ANSI92 option under Access Options/
Object Designers/Query Design/Sql Server Compatible Syntax is greyed
out.
Database is an Access 2007 database looking at Access 2007 tables
within the same database. I really want to avoid the whole querydefs
thing if I can.
Are you sure that JetSQL supports the DDL statements Create View/
Procedure? If so may I have the full steps please?
I can't give you any more than what is in the online help .. sorry.
In A2003, I did have to check the ANSI92 option for the database I was
testing with in order to make the CREATE VIEW statement work in the SQL View
of a query builder window. Without that option turned on, I got the same
error you did.
This snippet of code also failed until I turned on ANSI92:
Sub testcreateview()
Dim db As DAO.Database
Set db = CurrentDb
db.Execute "CREATE VIEW testqry AS select * from table1", dbFailOnError
End Sub
If you cannot turn on that option, it appears you will have to resort to the
querydef (or ADOX Views) method. I'm baffled as to why you are so desperate
to avoid it. Is it because of the need to create a Reference to DAO? If so,
you can do that in code by using the Application object's References
collection, which has two methods for creating references: AddFromFile and
AddFromGuid. Here is an example of the latter:
Dim ref As Reference, DAOfound As Boolean
DAOfound = False
For Each ref In Application.References
If ref.Name = "DAO" Then
DAOfound = True
exit for
End If
Next ref
If Not DAOfound Then
Application.References.AddFromGuid
"{00025E01-0000-0000-C000-000000000046}", 3, 6
End If
They are very simple to use. You don't even have to drop the querydef if
you've already created it - just set the .SQL property to the new sql
statement, like this:
sub createqry()
dim db as database,qdf as querydef,strsql as string
'build your string
set db=currentdb
on error resume next
set qdf=db.querydefs("qryname")
if err <> 0 then set qdf=db.createquerydef("qryname")
qdf.sql=strsql
end sub
--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
.
- References:
- Determining EVERY month between 2 given dates
- From: Edwinah63
- Re: Determining EVERY month between 2 given dates
- From: Allen Browne
- Re: Determining EVERY month between 2 given dates
- From: Edwinah63
- Re: Determining EVERY month between 2 given dates
- From: PieterLinden via AccessMonster.com
- Re: Determining EVERY month between 2 given dates
- From: Edwinah63
- Re: Determining EVERY month between 2 given dates
- From: Bob Barrows
- Re: Determining EVERY month between 2 given dates
- From: Edwinah63
- Determining EVERY month between 2 given dates
- Prev by Date: Re: Convert text to Combo
- Next by Date: Re: Determining EVERY month between 2 given dates
- Previous by thread: Re: Determining EVERY month between 2 given dates
- Next by thread: Re: Determining EVERY month between 2 given dates
- Index(es):
Relevant Pages
|