October 11, 2008 at 11:41 am
I have the following VBA code using DAO that I'm trying to convert to ADO for SQL Server. How can I modidy this code to get it working?
'looping through all queries, searching for query of interest
Dim varQuery As QueryDef
Dim varFoundQuery As Boolean
Set DB = CurrentDb
varFoundQuery = False
For Each varQuery In DB.QueryDefs
If varQuery.Name = "Forecasts" Then
varFoundQuery = True
Exit For
End If
Next
Thanks for any advice you can provide!
October 12, 2008 at 12:24 pm
Never done the conversion myself but from
http://www.dbforums.com/archive/index.php/t-947624.html
it should be
Well, the good news is I finally figured it out. Quite a switch from the old DAO methods, but I guess for the better.
For Each aob In CurrentData.AllQueries *(AllTables for tables)
Next aob
and... for forms, reports, modules, macros...etc...
For Each aob In CurrentProject.AllForms
Next aob
I just wonder why they have to change between CurrentProject and CurrentData for these. I guess it does make a little sense when I think about it...
Thanks for your help
Originally posted by basicmek
Try the ADOX Catalog object for enumerating the Views and Procedures in a database
October 14, 2008 at 2:15 pm
Thanks again Jo!
To get it working I added:
Dim aob As AccessObject
For Each aob In CurrentData.AllQueries
If aob.Name = "Query of Interest " Then
varFoundQuery = True
Exit For
End If
Next
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply