Mattster2020
01-13-2009, 04:36 AM
Morning All,
I have recently used the below code to create two command buttons and a text box, the command buttons are use to increment and deincrement values contained within the textbox. This functionality works fine when tested on the form Frm_Timesheet_Capture_1 directly.
The problem ocurs due to Frm_Timesheet_Capture_1 being used as a sub form on form Frm_Timesheet. The line highlighted in red below is the problem, I think.
Ive tried to use the property Screen.ActiveControl.Controls to reference the subform, but this doesnt work.
Could anyone point me in the right direction as to how I would get this working?
Function IncOrDecDate(intIncOrDec As Integer, strDateCtrl)
Dim intI As Integer
Dim objDateCtrl As Object
For intI = 1 To 1500 ' Start loop.
If intI Mod 100 = 0 Then ' If loop has repeated
' 100 times.
DoEvents ' Yield to operating
' system.
End If
Next intI
Set objDateCtrl = Screen.ActiveForm.Controls(strDateCtrl)
objDateCtrl.Value = objDateCtrl.Value + intIncOrDec
End Function
I have recently used the below code to create two command buttons and a text box, the command buttons are use to increment and deincrement values contained within the textbox. This functionality works fine when tested on the form Frm_Timesheet_Capture_1 directly.
The problem ocurs due to Frm_Timesheet_Capture_1 being used as a sub form on form Frm_Timesheet. The line highlighted in red below is the problem, I think.
Ive tried to use the property Screen.ActiveControl.Controls to reference the subform, but this doesnt work.
Could anyone point me in the right direction as to how I would get this working?
Function IncOrDecDate(intIncOrDec As Integer, strDateCtrl)
Dim intI As Integer
Dim objDateCtrl As Object
For intI = 1 To 1500 ' Start loop.
If intI Mod 100 = 0 Then ' If loop has repeated
' 100 times.
DoEvents ' Yield to operating
' system.
End If
Next intI
Set objDateCtrl = Screen.ActiveForm.Controls(strDateCtrl)
objDateCtrl.Value = objDateCtrl.Value + intIncOrDec
End Function