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
T148").Clear
' ....... my other code......
' Note: Double-quote character = Chr(34)
myRecordSet.Open SQL2_ [FONT="]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="]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!
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
' ....... my other code......
' Note: Double-quote character = Chr(34)
myRecordSet.Open SQL2_ [FONT="]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="]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: