wind20mph
MS Access User Since 1996
- Local time
- Today, 18:02
- Joined
- Mar 5, 2013
- Messages
- 50
Payroll main form to post attendance record. Before I open the attendance form, I wanted to check if there is a record in the sql statement.
The code below produces error MS Acces object "Variable or With Block Variable Not Set"
The code below produces error MS Acces object "Variable or With Block Variable Not Set"
Code:
Private Sub cmdPostAtt_Click()
Dim stSQL As String
Dim dbHBK As DAO.Database
Dim rsHBK As DAO.Recordset
If IsLoaded("pmkpayrollp") Then
stSQL = "SELECT * FROM attemain WHERE ((eid LIKE forms![pmpayentrya]![empno]) AND (pperiod LIKE forms![pmkpayrollp]![Text9]))"
'MsgBox Forms![pmpayentrya]![empno] & " - " & Forms![pmkpayrollp]![Text9]
Set dbHBK = CurrentDb
Set rsHBK = dbHBK.OpenRecordset(stSQL)
If rsHBK.RecordCount >= 1 Then
DoCmd.OpenForm "attpop", , , , , acDialog
Else
MsgBox "No attendance recorded", vbInformation + vbOKOnly, "Nothing to Post"
End If
Set rsHBK = Nothing
Else
MsgBox "No payroll period"
End If
End Sub