Non Table defined field usage on Form

justphilip2003

Registered User.
Local time
Today, 05:40
Joined
Mar 3, 2013
Messages
30
Is it possible to place a numeric field on a form that is not associated with any Table? It would be used to calculate a value that would be written to a Table field. I am trying to convert field InVal that is regular Ounces or Grams and convert to Troy ounces via buttons event criteria.

Private Sub CmdCvrtGm_Click()
TroyOz = [InVal] * 0.0322
End Sub

Private Sub CmdCvrtOz_Click()
TroyOz = [InVal] * 0.9115
End Sub

TIA JP :banghead:
 
Last edited:
Sure. You can place a value in an unbound control, understanding that it will be lost when the form is closed.
 
I've been away from Access coding to long!
I created an unbound field and it calculates but returns only integer answers. On Both InVal And TroyOz, Formats are set at General Number, Decimal set at 4. a screen print of TroyOz is always an integer.

Private Sub CmdCvrtOz_Click()
'Dim InVal As String
'Dim TroyOz As String
TroyOz = [InVal] * 0.9115
scrMessages = TroyOz
End Sub

What am I missing? TIA JP
 
What is the data type/size of TroyOz? I'm guessing Integer or Long Integer.
 
TroyOz is define as a General Number with 4 decimal places. I believe my problem is with using the unbound field InVal, I am not picking up the input from the Form; screen prints show the unbound field InVal being blank. Is there a command that fetches the value from the Form to do arithmetic operations?

I removed a[ dim InVal as Double] and the value is correctly screen printed but the TroyOZ bounded screen field remains 0, it should have been .7734; further test needed to see if it writes to Table.

The Table contained a 0 after writing to table yet the screen message showed a valid input.
TIA JP
 
Last edited:
That's a format, not a data type. You can be more explicit about where the value is coming from:

Forms!FormName.ControlName

Can you attach the db here?
 
How do I replicate your issue? The code appears to work. I put 1 in the convert textbox, hit Oz to Troy and .9115 appears in the message textbox. You code is not saving the value, it's just populating a variable. If you want it saved, you'd populate a bound textbox:

Me.TextboxName = [InVal] * 0.9115

If this was an attempt to save the value, it won't work:

MainTbl: TroyOZ = [InVal] * 0.9115
 
By the way, the data type info I was looking for was Double, the field size. That type is fine for holding decimals.
 

Users who are viewing this thread

Back
Top Bottom