m-taha
New member
- Local time
- Today, 18:47
- Joined
- Dec 6, 2019
- Messages
- 29
I have a form where employees register their daily work hours. I am trying to put a restriction on Temprary employees that since they work hourly wages they can't register hours as non-performance such as ( public holiday, vacations, sick leave or military duty, minus hours... etc). The employees are selected from a dropdown list and the non-performance option is set as a radio button ( when it's checked it gives me the non-performance dropdown list )
i want the temporary employees to not be able to check the radio button in the first place.
The code is supposed to check if the selected employee number is equal to that in the employee hours table and whether the temporary_field is set to True or not (of course in access it's -1) so it basically checks if the employee is actually temporary or not , and also checks the date (if it falls between the temporary employee's hire date and termination date )
i have tried 2 variatons :
1st attempt was regular recordset
and i tried both enabled and visible none of it worked, i put msgbox in between to see if it actually enters the if statement, turns out it doesn't!
____________________________________________________________________
2nd attempt was to use sql as string for the recordset
so this didn't work at all, i kept getting 3078 runtime error though i went and checked that i wrote and spelled everything correctly, even checked the direct vba window as well. bbut no luck there
______________________________
Ps.
i also tried this code on
Form_Load()
Form_Currrent()
After_Update()
Combobox_Change()
Combobox_Click()
I know some of these make no sense but i just tried for the sake of it...
but as you can see none worked
thank you so much in advance for any tips and clues as to how it might work or why it didn't
really appreciate it
i want the temporary employees to not be able to check the radio button in the first place.
The code is supposed to check if the selected employee number is equal to that in the employee hours table and whether the temporary_field is set to True or not (of course in access it's -1) so it basically checks if the employee is actually temporary or not , and also checks the date (if it falls between the temporary employee's hire date and termination date )
i have tried 2 variatons :
1st attempt was regular recordset
and i tried both enabled and visible none of it worked, i put msgbox in between to see if it actually enters the if statement, turns out it doesn't!
Code:
Private Sub PersNr_Change()
Dim db As DAO.Database
Dim rstpp As DAO.Recordset
Dim dateBegin As Date
Dim dateEnd As Date
Set db = CurrentDb
Set rstpp = db.OpenRecordset("tblPersonalStundenplanung", dbOpenDynaset, dbSeeChanges) //[this is the employee hours table]
dateBegin = rstpp!PersPlan_Datum_Beginn [hire date]
dateEnd = rstpp!PersPlan_Datum_Ende [termination date]
If Me!mDatum >= dateBegin And Me!mDatum <= dateEnd Then // [mDatum is the current date ]
MsgBox (Me!mDatum)
If Me!PersNr = rstpp!PersNr Then // [the employee number ]
MsgBox (Me!PersNr)
MsgBox (rstpp!PersNr)
If DLookup("PersPlan_Temporaere", "tblPersonalStundenplanung", "PersPlan_Temporaere = -1") Then //[temporary field]
MsgBox (DLookup("PersPlan_Temporaere", "tblPersonalStundenplanung", "PersPlan_Temporaere = -1"))
Me!Option191.Enabled = False
Me!LinkNr.Visible = False
End If
End If
End If
End Sub
2nd attempt was to use sql as string for the recordset
Code:
Private Sub PersNr_Change()
Dim db As DAO.Database
Dim rstpp As DAO.Recordset
Dim dateBegin As Date
Dim dateEnd As Date
Dim emp01 As String
emp01 = " SELECT * FROM tblPersonalStundenplanung WHERE PersPlan_Temporaere = -1 "
Set db = CurrentDb
Set rstpp = db.OpenRecordset("emp01", dbOpenDynaset, dbSeeChanges)
dateBegin = rstpp!PersPlan_Datum_Beginn
dateEnd = rstpp!PersPlan_Datum_Ende
If rstpp!PersNr = Me!PersNr.Value Then
MsgBox (Me!PersNr)
MsgBox (rstpp!PersNr)
If Forms!frmStundenrapport!mDatum >= dateBegin And Me!mDatum <= dateEnd Then
MsgBox (dateBegin)
MsgBox (Me!mDatum)
MsgBox (dateEnd)
MsgBox (rstpp!PersPlan_Temporaere)
Forms!frmStundenrapport!Option191!Enabled = False
Forms!frmStundenrapport!LinkNr.Enabled = False
End If
End If
End Sub
so this didn't work at all, i kept getting 3078 runtime error though i went and checked that i wrote and spelled everything correctly, even checked the direct vba window as well. bbut no luck there
______________________________
Ps.
i also tried this code on
Form_Load()
Form_Currrent()
After_Update()
Combobox_Change()
Combobox_Click()
I know some of these make no sense but i just tried for the sake of it...
but as you can see none worked
thank you so much in advance for any tips and clues as to how it might work or why it didn't
really appreciate it