I'm have a couple of problems. The first is with referencing a Subform within another Subform. The Main Form is called frmTimeCard, within it is the Subform named frmClockIn, and within it are two forms, frmClockOut and frmClockIn_Sub. There are a few
bits of code I'm having trouble with, but I think if someone can put me on the right path I can fix the rest. Upon clicking the button to Clock out I want the frmClockIn_SUB to requery and refresh, but nothing happens. Below are codes I've tried with no
success. First note the button is located on the frmClockIn_Sub.
I've tried all of the following:
Forms("frmTimeCard").Controls("frmClockIn").Form.Controls("frmClockIn_SUB").Form.Requery
Forms("frmTimeCard").Controls("frmClockIn").Form.Controls("frmClockIn_SUB").Form.Refresh
Forms!frmTimeCard!frmClockIn.Form!frmClockIn_SUB.Form.Requery
Forms!frmTimeCard!frmClockIn.Form!frmClockIn_SUB.Form.Refresh
Forms!frmTimeCard.frmClockIn.Form.frmClockIn_SUB.Requery
Forms!frmTimeCard.frmClockIn.Form.frmClockIn_SUB.Form.Refresh
I can only get the form to update by exiting or by clicking the Refresh icon on the Home tab.
My second problem is somewhat similar and has to do with clicking the ClockIn button, which is located on the frmClockIn. Below you will find the code I'm using. Most of it runs fine except what's in bold.
Me.frmClockIn_SUB.SetFocus
Me.frmClockIn_SUB!TimeID.SetFocus
DoCmd.GoToRecord , , acNewRec
Me.frmClockIn_SUB!TimeIN = Now
Me.frmClockIn_SUB!DayName = Date
Me.frmClockIn_SUB!PayPeriodID = Forms!frmTimeCard!frmClockIn.Form.PayPeriodID
MsgBox "You have successfully clocked in at " & Now(), vbOKOnly
RunCommand acCmdSaveRecord
All seems to run smoothly, except it's not adding the PayPeriodID to the table. Note: PayPeriodID is on the frmTimeCard and has an AutoNumber data type, which could be the issue, just not sure. If so, not sure how to fix it.
Please help,
Mike