Integer Returned instead of General Number

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!
 
K

Klatuu

There is no such thing in Access as a General Number. That would be an Excel
thing.
What is it you are wanting to do?
 
D

Damon Heron

Klatuu--
I think the poster is talking about the format property "General Number".
He seems to have two textboxes. He should check the format property of
both, since they are involved in some sort of calculation. I am guessing
they are unbound, also.

Damon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top