Run series of files in the same function - Help please!

2learn

New member
Local time
Yesterday, 18:01
Joined
Jul 18, 2010
Messages
1
Hello, I am new with vba with Access, but I have to learn it fast for my work. Here comes the challenge, I need to run series of sheets in the same function, how do I do this? I have an idea, but it is not working:

Dim TabOrder As Variant, X As Variant
'For example, need to run the following series of sheets

TabOrder = Array(“EX_086”, "EX _015", " EX _018_019", " EX _IB_Retail", _
" EX _IB_Public", " EX _009", " EX _068", " EX _035_000")
For Each X In TabOrder
Dim myRecordSet As ADODB.Recordset
Sheets(X).Range("C5:DT148").Clear
' ....... my other code......
' Note: Double-quote character = Chr(34)
myRecordSet.Open SQL2_ [FONT=&quot]EX_086[/FONT].Value, _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & DatabaseLocationTextbox.Value & ";", _
adOpenForwardOnly, adLockReadOnly, adCmdText
'........my other code.....
Next

myRecordSet.Close
Set myRecordSet = Nothing
' The end


My question is, for the highlight area, how do I replace [FONT=&quot]EX_086 [/FONT] with X variable to run all the list of sheets? For the highlight textbox value, can I put the info in an excel cell and take the value out in that way. In another word, does access only recognize testbox value?
Thanks!:)
 
Last edited:
Hi

I'm not very strong with Excel, but when I nead Excel Data in Access I import it as a linked table:
DoCmd.TransferSpreadsheet acLink, [SpreadsheetType], [TableName], [fileName], [HasFieldNames], [Range]

You can find help on this.

Good luck!
 

Users who are viewing this thread

Back
Top Bottom