I am using the following code sucessfully to retun the number of records in a SQL statement.
but I would like to use the same procedure on several tables. Can I use my Recordset in a loop for example and re-set the SQL to populate another text box with a new value. So if I have 7 tables (TblMod1 - TblMod7) just change this value in each SQL and point it to Txt_Mod1Waiting.Value - Txt_Mod7Waiting.Value.
Code:
Dim StrSql As String
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenStatic
'---------- Get count for Module 1 waiting
StrSql = "SELECT TblMod1.Fld_Mod1_Index, TblMod1.Fld_Mod1TestResult FROM TblMod1 WHERE (((TblMod1.Fld_Mod1TestResult)=""""));"
rst.source = StrSql
rst.Open
Txt_Mod1Waiting.Value = rst.RecordCount & " waiting"
rst.Close
Set rst = Nothing
but I would like to use the same procedure on several tables. Can I use my Recordset in a loop for example and re-set the SQL to populate another text box with a new value. So if I have 7 tables (TblMod1 - TblMod7) just change this value in each SQL and point it to Txt_Mod1Waiting.Value - Txt_Mod7Waiting.Value.