D
DeDBlanK
Hello, green VBA Coder here
Probably a simple answer here.
I have modied code from Allen Browne's code for the ajbCalendar code.
Instead of using it for a calendar popup, I am using it for a
calculation.
The issue is that when the return value is called back to the form
textbox, the number is an integer and not a general number. Do I need
to call out a something specific for a General number to prevent the
integer?
Here's the code:
Option Compare Database
Option Explicit
Private Const conMod = "frmCycleRateCalculator"
Private Sub Form_Open(Cancel As Integer)
'On Error GoTo Form_Open_Err
Dim bEnabled As Boolean
'Initialize Cycle to the existing number, or 60 if <>0.
If gtxtRate <> 0 Then
Me.txtPart = gtxtRate.Value
Else
Me.txtPart = 60
End If
'Lock the Ok button if the text box is locked or disabled.
bEnabled = (gtxtRate.Enabled) And (Not gtxtRate.Locked)
With Me.cmdOk
If .Enabled <> bEnabled Then
.Enabled = bEnabled
End If
End With
'Set the title
If Len(Me.OpenArgs) > 0& Then
Me.Caption = Me.OpenArgs
End If
Form_Open_Exit:
Exit Sub
Form_Open_Err:
MsgBox Err.Description, vbCritical,
"frmCycleRateCalculator.Form_Open"
Resume Form_Open_Exit
End Sub
**********************************This is where I believe the issue
might be*************************
Private Sub cmdOk_Click()
On Error Resume Next
'Purpose: Transfer the result back to the calling text box (if
there is one), and close.
If Me.cmdOk.Enabled Then
gtxtRate.Value = Me.txtPart / Me.txtTime
'Check Value of gtxtRate --Testing purpose only
MsgBox gtxtRate, vbOKOnly, "test"
End If
gtxtRate.SetFocus
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub
**********************************************************************************
Appreciate any help.
Thanks in advance!
Probably a simple answer here.
I have modied code from Allen Browne's code for the ajbCalendar code.
Instead of using it for a calendar popup, I am using it for a
calculation.
The issue is that when the return value is called back to the form
textbox, the number is an integer and not a general number. Do I need
to call out a something specific for a General number to prevent the
integer?
Here's the code:
Option Compare Database
Option Explicit
Private Const conMod = "frmCycleRateCalculator"
Private Sub Form_Open(Cancel As Integer)
'On Error GoTo Form_Open_Err
Dim bEnabled As Boolean
'Initialize Cycle to the existing number, or 60 if <>0.
If gtxtRate <> 0 Then
Me.txtPart = gtxtRate.Value
Else
Me.txtPart = 60
End If
'Lock the Ok button if the text box is locked or disabled.
bEnabled = (gtxtRate.Enabled) And (Not gtxtRate.Locked)
With Me.cmdOk
If .Enabled <> bEnabled Then
.Enabled = bEnabled
End If
End With
'Set the title
If Len(Me.OpenArgs) > 0& Then
Me.Caption = Me.OpenArgs
End If
Form_Open_Exit:
Exit Sub
Form_Open_Err:
MsgBox Err.Description, vbCritical,
"frmCycleRateCalculator.Form_Open"
Resume Form_Open_Exit
End Sub
**********************************This is where I believe the issue
might be*************************
Private Sub cmdOk_Click()
On Error Resume Next
'Purpose: Transfer the result back to the calling text box (if
there is one), and close.
If Me.cmdOk.Enabled Then
gtxtRate.Value = Me.txtPart / Me.txtTime
'Check Value of gtxtRate --Testing purpose only
MsgBox gtxtRate, vbOKOnly, "test"
End If
gtxtRate.SetFocus
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub
**********************************************************************************
Appreciate any help.
Thanks in advance!