*?*FILTER TABLE on 'Sub Form_Open' Event-VBA Code*?*
Posted on 2001-08-06
I need to apply a TABLE/RECORDSET FILTER to
Me.Batch_AmtPaid = DSum("[PY_TTL]", "qryBATCH_OPEN_TTL")
Function during the Sub Form_Load Event. The 'Filter' Value(PAY_PER) is determined by the PAY_PER value in the last record/row of the Pay_BatchOpen Table in the 'Sub Form_Open' Event?
I either get a Type Mismatch Err in the OpenRecordset when trying to execute the Code or the Nothing is executed - ie the FILTER is not implemented.
This would be analogous to a PARAMETER SELECT QUERY, except instead of the User entering the specific value when the Query is executed, it is automatically loaded from a VBA Code Variable.
SPECIFIC QUESTION: How is a Filter property automatically implemented from VBA Event Code and what does the Code look like, ie a specific example or detail?
EVENT CODE(Sub Form_Open)
Dim Db As Database
Set Db = CurrentDb()
Dim rsTblPay_BatchOpen As Recordset
Set rsTblPay_BatchOpen = Db.OpenRecordset("tblPay_BatchOpen", dbOpenDynaset)
Dim PP_Filter As Variant
PP_Filter = rsTblPay_BatchOpen!PAY_PER
'Me.Filter = PP_Filter
Dim rsTblTime_Cards As Recordset
Set rsTblTime_Cards = Db.OpenRecordset("Select * From tblTime_Cards Where PAY_PER = ' PP_Filter' ", dbOpenDynaset)