URGENT: Access and sendkeys to another app

  • Thread starter Thread starter Chris Shaw
  • Start date Start date
C

Chris Shaw

Can anyone help.

I have an access database with a couple of thousand records in it ...
:shock:

problem is i need to type one of the fields values into a data
entry window for another application putting an enter between each record
... e.g.

In Access (data from a query)

12345 XYZ Corp TYPE1
34293 SDJK Corp TYPE2


And this needs to come out as ...

12345
34293

Can anyone give me a clue as to how i can do this asap - i need to type it
5 times into different programs in the other app. :x And i cant do a
cut / paste!

Is there any way i can use a sendkeys macro? or some VBA code?

Any help greatly appreciated...

Please if you reply can you also cc the mail address above removing the
spam message!!!
 
Chris Shaw said:
Can anyone help.

I have an access database with a couple of thousand records in it ...

problem is i need to type one of the fields values into a data
entry window for another application putting an enter between each
record .. e.g.

In Access (data from a query)

12345 XYZ Corp TYPE1
34293 SDJK Corp TYPE2


And this needs to come out as ...

12345
34293

Can anyone give me a clue as to how i can do this asap - i need to
type it 5 times into different programs in the other app. :x And i
cant do a cut / paste!

Is there any way i can use a sendkeys macro? or some VBA code?

Any help greatly appreciated...

SendKeys is not reliable, as you aren't guaranteed of the correct
application having the focus. Automation would be better, if the other
application is automatable. But if you gotta, you gotta.

If you're stuck with using SendKeys, that statement itself shouldn't be
a problem. Let's suppose you open a recordset on the query that returns
the records and fields you want. This part of it might look something
like this:

Dim rs As DAO.Recordset

Set rs = CurrentDB.OpenRecordset("TheQuery")

With rs
Do Until .EOF

' ... somehow activate the other application ...

' Send the value of the first field as a series of
' keystrokes, followed by a CR/LF.
SendKeys .Fields(0).Value & vbCrLf

' Move to the next record.
.MoveNext
Loop
.Close
End With

Set rs = Nothing

What I don't know offhand is how to assure that the desired application
has the focus. There'll probably be some API code involved, and I'm
sure it can be worked out.
Please if you reply can you also cc the mail address above removing
the spam message!!!

No, sorry, I've no time for that.
 
Back
Top