Update query

J

John Reynolds

I have a few update queries I wasjust curious to know
whether it would be better to put these together in a
module.

Some of these are below. How do I put them together in a
module. When OP WL is my main table, Translate is
my 'translate' table and the rest are fields.


UPDATE [OP WL] INNER JOIN [Translate SourceRef] ON [OP
WL].SOURCEREF = [Translate SourceRef].Was SET [OP
WL].SOURCEREF = [Translate Purch_Code].ShouldBe;

UPDATE [OP WL] INNER JOIN [Translate Purch_Code] ON [OP
WL].PURCODE = [Translate Purch_Code].Was SET [OP
WL].PURCODE = [Translate Purch_Code].ShouldBe;

UPDATE [OP WL] SET [OP WL].NHSNO = LTrim([OP WL]![NHSNO]);
 
S

SA

John:

Your post is unclear. If these are saved update queries or stored
procedures, then don't put them in a module in SQL code, they will run more
slowly that way. However, if they are saved queries and you wanted to run
time together via a function, then that's easy to do as the code below:

HTH
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg

----------------------------

Function RunUpdates()
Dim Conn as Adodb.Connection
Dim Cmd as ADODB.Command

Set conn = CurrentProject.Connection
Set Cmd = New ADODB.Command

With Cmd
'1st Query
.ActiveConnection = Conn
.CommandType = adCmdStoredProc
.CommandText = "NameOfYourSavedUpdateQuery"
.Execute , , , adExecuteNoRecords
'2nd
.CommandText = "NameOfYour2ndSavedUpdateQuery"
.Execute , , , adExecuteNoRecords
'3rd
.CommandText = "NameOfYour3rdSavedUpdateQuery"
.Execute , , , adExecuteNoRecords
End with
Set Cmd = Nothing
Set Conn = Nothing
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top