Good day,
I have a program that the user wants the record be filtered by cut-off date. After I pressed the command button cmdloaddata. I encountered an error message of "Object variable or With block variable not set". Can anyone help me to fix this stuff. Thank you...
I have a program that the user wants the record be filtered by cut-off date. After I pressed the command button cmdloaddata. I encountered an error message of "Object variable or With block variable not set". Can anyone help me to fix this stuff. Thank you...
Code:
Private Sub Form_Load() Dim rSConn As ADODB.Connection Set rSConn = New ADODB.Connection rSConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Payroll System\Payroll\DBPayroll.accdb;Persist Security Info=False" rSConn.Open End Sub
Code:
Private Sub cmdLoadData_Click() Dim rs As New ADODB.Recordset If rS.State = adStateOpen Then rS.Close End If rS.CursorLocation = adUseClient rS.Open "Select * from pr_dtl where cut_off_date_frm ='" & dtFrom & "' and cut_off_date_to='" & dtTo & "'", rSConn, adOpenDynamic, adLockOptimistic, adCmdText rS.Filter = "cut_off_date_frm ='" & dtFrom & "'" And "cut_off_date_to='" & dtTo & "'" If rS.RecordCount > 0 Then 'display the filtered results in the grid Call DataLoad End If End Sub
Comment