Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

insert statement in vba

Posted on 2014-10-28
2
Medium Priority
?
252 Views
Last Modified: 2014-11-06
Hi,
I was wondering if I can get some help with an insert statement I am running in vba.

I need to insert some records based on the current form

my code is something like this:
CurrentDb.Execute "insert into SER_FAXES_FILE ([ID],[STAFF-Resource NAME OT], [ADDRESS UNIQUE ID]) values (SELECT [ID],[STAFF-Resource NAME OT], [ADDRESS UNIQUE ID] from SER_FAXES_FILE_daily where SER_FAXES_FILE.ID = me.id))"

Open in new window


can I do a insert with a select statement with currentdb.execute? its erroriing out

thanks in advance
Vinnie
0
Comment
Question by:damixa
2 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 40408792
if the ID field is Number

CurrentDb.Execute "insert into SER_FAXES_FILE ([ID],[STAFF-Resource NAME OT], [ADDRESS UNIQUE ID]) SELECT [ID],[STAFF-Resource NAME OT], [ADDRESS UNIQUE ID] from SER_FAXES_FILE_daily where SER_FAXES_FILE.ID =" & me.id

if the ID field is TEXT

CurrentDb.Execute "insert into SER_FAXES_FILE ([ID],[STAFF-Resource NAME OT], [ADDRESS UNIQUE ID]) SELECT [ID],[STAFF-Resource NAME OT], [ADDRESS UNIQUE ID] from SER_FAXES_FILE_daily where SER_FAXES_FILE.ID ='" & me.id & "'"
0
 
LVL 7

Expert Comment

by:slubek
ID: 40409343
Create stored procedure on server side and exec it with something like:
CurrentDb.Execute "exec sp_yourprocedurename " & [ID] & ", " & [STAFF-Resource NAME OT] (etc.)

Open in new window

First of all - you can embed into SP any logic you want, second, you can exec that procedure from more application functions than one.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question