Hi everyone, I have a simple database which is storing annual leave applications and their approval status. I have a Employee form (frmEmployeeDetails) showing employee details. I have a button on that form which opens another form and allows the user to enter the last working day (date), return to work day (date) from calendar. A function then calculates annual leave days and public holidays based on those dates. A recordset is created for each week of leave. I have a button on the form which creates the recordset(s) to load into a subform (frmALSched) on the form (Form1). This is where the problem occurs.
Using DAO recordset to create a new record and enter each record into the subform, which was working great, until now. For some reason the form on which the subform exists is not the active form even after I set it as such. When the code reaches the following lines
With Forms!Form1!frmALSched.Form
DoCmd.GoToRecord , , acNewRec
The frmEmployeeDetails form actually goes to a new Record. Obviously, it appears to have the focus.
So I tried the folllowing lines of code:
Forms!Form1.SetFocus 'Sets focus on the form containing the subform
Me!frmALSched.SetFocus 'Sets focus on the subform control
Set frmCurrentForm = Screen.ActiveForm
Debug.Print "Current form is " & frmCurrentForm.Name
I receive this "Current form is frmEmployeeDetails" in the immediate window.
I cannot understand or workout why the Form1 isn't the form in focus as I believe I have set focus on Form1.ALSched.
Any advice will be greatly appreciated. I have come to the breaking point stage after trying to crack this one for the past few days.
Using DAO recordset to create a new record and enter each record into the subform, which was working great, until now. For some reason the form on which the subform exists is not the active form even after I set it as such. When the code reaches the following lines
With Forms!Form1!frmALSched.Form
DoCmd.GoToRecord , , acNewRec
The frmEmployeeDetails form actually goes to a new Record. Obviously, it appears to have the focus.
So I tried the folllowing lines of code:
Forms!Form1.SetFocus 'Sets focus on the form containing the subform
Me!frmALSched.SetFocus 'Sets focus on the subform control
Set frmCurrentForm = Screen.ActiveForm
Debug.Print "Current form is " & frmCurrentForm.Name
I receive this "Current form is frmEmployeeDetails" in the immediate window.
I cannot understand or workout why the Form1 isn't the form in focus as I believe I have set focus on Form1.ALSched.
Any advice will be greatly appreciated. I have come to the breaking point stage after trying to crack this one for the past few days.