Microsoft Access - Is there any other way on how to display values to textboxes using internal syntax?
Asked By Yves Val Miraflor on 07-Jul-12 01:24 AM
FIGURE 1.0
I have here a screenshot of sales entry form. Im declaring variables to in order to have a temporary storage on the figures given from the user. and
what i'd like to happen is the program will calculate the dimension H x W x rate per sqrft x No. of Pcs and the total of this figures will be displayed at the total sales.
i created a Textbox that would display separate total calculated of the dimension. the result of this would be calculated to Rate per sqrft and then to No. of Pcs.
Out of the Total would be less to expenses which result would be display to Margin textbox.
I have here a simplified formula in which im not quite sure if this is right.
Dim tempTotal As Double
Dim tempMargin As Double
Dim trpRateSize As Double
trpRateSize = Val(txtH.Value) * Val(txtW.Value)
tempTotal = Val(trpRateSize) * Val(txtSqrFt.Value)
txtMrgn.Value = Val(txtTotal.Value) - Val(txtExp.Value)
txtTotal.Value = Val(tempTotal) * Val(txtPcs.Value)
Hope to hear from you sir. Much appreciated..
wally eye replied to Yves Val Miraflor on 09-Jul-12 11:14 AM
It looks like you are trying to calculate the margin before you calculate the total, but the margin is dependent upon the total. Swap those two lines around, you should be good.
If you aren't doing it elsewhere, you might want to make sure you validate the input before you do your calculations.
Pat Hartman replied to Yves Val Miraflor on 29-Jul-12 05:57 PM
By using the syntax - txtW.Value - you are missing out on intellisense. Use Me.txtW and Acceww will auto-complete and also provide properties, etc.
.Value is the default property of a control and so can be and usually is omitted. If you are familiar with VB, you may remember that .Text is the default property there. In Access the .text property is only available when the control you are referencing actually has the focus so it is only used in events such as on Change which runs for each character as it is typed.