cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MisterH
Helper I
Helper I

Running MS Access saved Insert and Update queries

Hi Everyone,

 

I have an MS Access database that I am working with and there are a number of stored parametised queries for inserting and updating records. Is there a way to 'call' these stored queries to add and update records, or am I going to have to grab the SQL from each one and re-create it in PAD? I am not the maintainer of this database so I would very much like to be able to use the saved queries if possible.

Thanks for taking a look at this for me. Any help greatly appreciated.

@MisterH

1 ACCEPTED SOLUTION

Accepted Solutions
MisterH
Helper I
Helper I

Hi Kinuasa,

Thanks for having a crack at this. What you are suggesting is to step outside the flow altogether which defeats the purpose of having the control of the flow.

I have discovered the answer though:

eg/        EXECUTE [yourQueryNameHere] "Some Text Value"

 

The values that you place after the [yourQueryNameHere] need to be in the order they are specified in the query (the one you are calling in MS Access). The data types should also match.

 

eg/         EXECUTE [yourQueryNameHere] "Some Text Value", 123.45, "Another Text Value"

 

I hope this helps anyone else looking to execute queries, particularly parametised ones inside of MS Access.

 

Cheers

 

MisterH

View solution in original post

2 REPLIES 2
kinuasa
Resolver II
Resolver II

Hi,
I suggest that to run a script like the following using the "Run VBScript" action.

 

Regards,
kinuasa

 

Dim con 'ADODB.Connection
Dim cmd 'ADODB.Command
Const DBFilePath = "C:\Test\Sample.accdb"
Const QueryName = "TargetQuery"

Set con = CreateObject("ADODB.Connection")
con.Open "Provider=Microsoft.ACE.OLEDB.16.0;Data Source=" & DBFilePath & ";Persist Security Info=False;"
With CreateObject("ADOX.Catalog")
  Set .ActiveConnection = con
  Set cmd = .Procedures(QueryName).Command
  cmd.Execute
End With
con.Close
MisterH
Helper I
Helper I

Hi Kinuasa,

Thanks for having a crack at this. What you are suggesting is to step outside the flow altogether which defeats the purpose of having the control of the flow.

I have discovered the answer though:

eg/        EXECUTE [yourQueryNameHere] "Some Text Value"

 

The values that you place after the [yourQueryNameHere] need to be in the order they are specified in the query (the one you are calling in MS Access). The data types should also match.

 

eg/         EXECUTE [yourQueryNameHere] "Some Text Value", 123.45, "Another Text Value"

 

I hope this helps anyone else looking to execute queries, particularly parametised ones inside of MS Access.

 

Cheers

 

MisterH

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Top Solution Authors
Top Kudoed Authors
Users online (4,444)