Re: Determining EVERY month between 2 given dates



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"


.



Relevant Pages

  • Re: Library Database
    ... Add a trusted location for the folder D:\TestLibCall. ... Create a new database in the folder, ... The last syntax, using a path, STILL fails. ... it appears that I cannot call the library function without a reference. ...
    (comp.databases.ms-access)
  • cdt glossary 0.1.4
    ... This glossary seeks to limit lengthy misunderstandings ... basic database research and mathematics. ... When context matters, it is provided. ... It is /not/ the same as a reference. ...
    (comp.databases.theory)
  • Re: I found the problem.
    ... manually relinking tables works and it opens fine if I've done a compact before reopening. ... Old database is working just fine with the "Microsoft Office 14 Access ... Data Object Engine" reference. ...
    (comp.databases.ms-access)
  • Re: Controlsource wont let Dlookup to enter
    ... Frustrated from entering the expression manually, using the syntax suggested ... ControlSource and clicked the Dlookup function from the list of functions. ... Is this happening in all controls on all forms in this database? ... Do you have the ClientID field bound to a control on the form? ...
    (microsoft.public.access.gettingstarted)
  • RE: MSOWCF Dll File
    ... Tom, Thanks again. ... > options and any required references that were checked in the source database. ... > Data to create new linked tables, instead of importing existing linked tables. ... > fine without the reference. ...
    (microsoft.public.access.setupconfig)