Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Macro from Access

Status
Not open for further replies.

ptw78

Technical User
Mar 5, 2009
155
US
I have an access database. I have a query that I run w/a button on a form in access. How can I have access run a macro in VBA to input some of the data into Attachmate from the query I run. I've seen people do it w/a form, but not a table from a query which is what I have. Here is some of the code I have to put the data into Attachmate, but I'm lost when it comes to dealing w/the table

Code:
Sub Main
    
Dim Sessions, System As Object, Sess0 As Object
Set System = CreateObject("EXTRA.System")
Set Sessions = System.Sessions
Set Sess0 = System.ActiveSession

Do

Sub Main
    
Sess0.Screen.Moveto 5,73
Sess0.Screen.Sendkey              
'this is where i dont know how get 'the account number from the query/table that was ran, 'and what to do after that.


Loop Until IsNull(Account Number)


End Sub

 
Anyone know if this is possible?
 


Hi,

Seems you might want a FUNCTION that returns a value given the account number on a psrticular row.

What are you trying to return from your session/screen?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I'm not wanting to return anything from the screen. What I'm wanting to do is take the account number and there is another row called Code, and put them into the screen, first I would need to put the account number in, hit enter, then put the code in and hit enter again and repeat until it's gone thru them all.
 



Since you're running this from MS Access, I'd suggest posting in forum705.

I do ALL my Extra coding in Excel, since I always have data listed on a sheet for loading a screen. I'd do the query to your MS Access DB on an Excel sheet, loop thru the rows in the resultset to do what you apparently need to do -- which sounds like you're updating the mainframe with this account/code data.

If you want help doing this in Excel, post in forum707.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Correct I'm updating mainframe w/the Code field after I put in the account. I've seen it ran directly from a form in access but wasn't sure if it can be done directly from a table.
 


Yes, you can loop thru the rows in a table. You must set a reference to the DAO recordset library and then declare objects for yoiur database and recordset. Open the recordset and loop thru each row.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Can you post an example of that. Not sure I quite udnerstand
 



That's why I suggested you post in forum705. I am not an Access VBA programmer. I can muddle thru, but I am not familiar with the Access Object Model or the DAO Object Model.

I am very familiar with the Excel Object Model and the ADO Object Model, which I use to grab data from Oracle, DB2, Access, Excel.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top