Open Access Macro, then put a value into a parameter field

B

BigPig

Hello All,

I can't figure out how to put data from excel into a 'parameter' field once
an access macro has been called from excel.

In Access, a small userform appears with the title "Enter Parameter Value".

I can get the Access macro to start, but can't figure out how to do the
rest. I tried sendkeys but that didn't work. Please see my code so far...

Private Sub cmdveerpqr_Click()

'<<< Opens the OPM Database and opens the 'Open PQR' macro

Dim LPath As String

'<<< Procedure to copy the "SSN" field data

txtveerappssn.SelStart = 0
txtveerappssn.SelLength = txtveerappssn.TextLength
txtveerappssn.Copy


'<<< Back to the database

LPath = "\\afilepath\another\opm_XP.mdb"

Set oApp = CreateObject("Access.Application")
oApp.Visible = True

oApp.OpenCurrentDatabase LPath

oApp.DoCmd.RunMacro "Open PQR"

***This is where I'm stumped, and I know sendkeys is the most unpreffered
way of getting this to work, but I thought to give it a shot.

Application.SendKeys "^v"

End Sub


Any help would be greatly appreciated.
 
M

merjet

You don't need to open Access. You can do it in the background using
DAO or ADO. For example:

Dim db As DAO.Database
Dim rs As Recordset
Dim qdf As QueryDef

Set qdf = db.QueryDefs("Query1")
qdf("ID") = 101
Set rs = qdf.OpenRecordset

For the above to work, Microsoft DAO x.xx Object Library must be
checked using the VBE menu Tools | References. For more info, see
here:
http://www.erlandsendata.no/english/index.php?t=envbadac

Hth,
Merjet
 

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