Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 13th, 2006, 04:05 PM
eighthman11
Guest
 
Posts: n/a
Default Open and save query with code

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

  #2  
Old November 14th, 2006, 04:05 AM
Kelii
Guest
 
Posts: n/a
Default Re: Open and save query with code


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

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles