By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,847 Members | 2,161 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,847 IT Pros & Developers. It's quick & easy.

Open and save query with code

P: n/a
Hello everyone. I have a table linked to an excel spreadsheet. I have
an append query based on this link table. I receive an error when I
run the append query "numeric field overflow". I have noticed that
when I open then save the append query and then run it I get no error.
I am assuming that the error is being caused by Access Optimizing. The
easy solution to my problem is if it is possible to run some VB code
that will save my append query before I run my append query.

Is there a way With code to open and save a query? Thanks

Nov 13 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

eighthman11,

If I'm interpreting your question correctly, yes there is an easy way
to create and save a query with code.

Public Sub CreateQuery (strName as String, strSQL as String)
Dim dbs as Database
Dim qdf as Querydef

Set dbs = CurrentDb
Set qdf = dbs.CreateQueryDef(strName, strSQL)

Set qdf = Nothing
Set dbs = Nothing

End Sub

Of course for this to work you need to be able to write a SQL statement
that fits your needs. As a side note, the above is accomplished through
DAO, most advanced developers use ADO as their preferred alternative.
However, if you are working solely through Access/VBA, then DAO is
quite sufficient.

Kelii

Nov 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.