K
k9smrt
I have a function that I would like to reuse. It uses a recordset.
My question is how can I or is this even possible, use the rs as a generic
field?
strColumn1 = rs!Column1
strColumn2 = rs!Column2
Column1 and Column2 are not the field names.
Code:
Function ReuseFunction(strTable1 As String, strColumn1 As String, strColumn2
As String)
Dim db As DAO.Database, rs As DAO.Recordset, strSQL As String
Set db = CurrentDb()
strSQL = "SELECT" & strColumn1 & "," & strColumn2 & "FROM" & strTable1 _
& "ORDER BY " & strColumn1 & "," & strColumn2 & "ASC"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If Not rs.BOF And Not rs.EOF Then
rs.MoveFirst
strColumn1 = rs!Column1
strColumn2 = rs!Column2
....
....
Set rs = Nothing
Set db = Nothing
End Function
My question is how can I or is this even possible, use the rs as a generic
field?
strColumn1 = rs!Column1
strColumn2 = rs!Column2
Column1 and Column2 are not the field names.
Code:
Function ReuseFunction(strTable1 As String, strColumn1 As String, strColumn2
As String)
Dim db As DAO.Database, rs As DAO.Recordset, strSQL As String
Set db = CurrentDb()
strSQL = "SELECT" & strColumn1 & "," & strColumn2 & "FROM" & strTable1 _
& "ORDER BY " & strColumn1 & "," & strColumn2 & "ASC"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If Not rs.BOF And Not rs.EOF Then
rs.MoveFirst
strColumn1 = rs!Column1
strColumn2 = rs!Column2
....
....
Set rs = Nothing
Set db = Nothing
End Function