I am an MS Access rookie. I am trying to create a sub routine in a module and would like to have two parameters in the Sub. The first parameter is the name of a table, and the second the name of a form. In the code below I have only put the type of parameter I would like to put in the sub realizing that it is not correct. I have tried using a string for the table name, and as forms do not have a name property I don't know how to identify a form as a parameter. The code follows:
Public Sub Expenses(tbx As String, frm As Form_frmExpenses) 'Do not know how to insert these parameters
Dim db As DAO.Database
Set db = CurrentDb
Dim rst As DAO.Recordset
Dim strSQL As String
Dim recEID As Integer
"FROM " & tbEx & _
"WHERE " & tbEx & ".[ExpenseID} > 0 " & _
"ORDER BY " & tbEx & ".[ExpenseID];"
Set rst = db.OpenRecordset(strSQL)
rst.MoveFirst
rst.MoveLast
recEID = rst!ExpenseID
frm.tbExpenseID.Value = recEID
recDoP = rst!DateOfPurchase
frm.tbDateOfPurchase.Value = recDoP
rst.Close
Set rst = Nothing
End Sub
Public Sub Expenses(tbx As String, frm As Form_frmExpenses) 'Do not know how to insert these parameters
Dim db As DAO.Database
Set db = CurrentDb
Dim rst As DAO.Recordset
Dim strSQL As String
Dim recEID As Integer
"FROM " & tbEx & _
"WHERE " & tbEx & ".[ExpenseID} > 0 " & _
"ORDER BY " & tbEx & ".[ExpenseID];"
Set rst = db.OpenRecordset(strSQL)
rst.MoveFirst
rst.MoveLast
recEID = rst!ExpenseID
frm.tbExpenseID.Value = recEID
recDoP = rst!DateOfPurchase
frm.tbDateOfPurchase.Value = recDoP
rst.Close
Set rst = Nothing
End Sub