Percentage figures not transferring from textbox to bound text box correctly

chrisjames25

Registered User.
Local time
Today, 15:29
Joined
Dec 1, 2014
Messages
404
Hi All

I have a form whereby a user inputs into unbound textboxes/comboboxes. On clicking thge cmd button these inputs get transferred to bound textboxes.

This all works great other than a textbox whereby I have the format set as a percentage. The unbound txt box is txt_YieldPer and the bound one is Bound_YieldPer.

This is the following code i use to transfer the data:

Code:
Me.Bound_QtyPotted.Value = Me.Txt_QtyPotted.Value
Me.Bound_YieldPer.Value = Me.Txt_YieldPer.Value
Me.Bound_YieldQty.Value = Me.Txt_YieldQty.Value
Me.Bound_DiscPots.Value = Me.Txt_DiscPots.Value
Me.Bound_DiscUnits.Value = Me.Txt_DiscUnits.Value
Me.Bound_PredictedLoss.Value = Me.Txt_PredictedLoss.Value
Me.Bound_MixBatchNo.Value = Me.Txt_MixBatchNo.Value

If i have entered 95% in the unbound txtbox it reads as 0.95 as i toggle through the code but the bound_yieldper becomes 1 rather than 0.95.

Both textboxes are formatted as percentage. The bound field I have tried as an integer with format % and get the result of "1". I have tried it as a decimal formatted as a percentage and get the result of "0". No idea why this is not working like all other textboxes.

Any help would be great
 
Make sure to NOT use an integer data type.
Assign the vale to a Single type to keep the decimal part.
 
Your a star. Worked a treat.
 
Hi All

I have a form whereby a user inputs into unbound textboxes/comboboxes. On clicking thge cmd button these inputs get transferred to bound textboxes.

This all works great other than a textbox whereby I have the format set as a percentage. The unbound txt box is txt_YieldPer and the bound one is Bound_YieldPer.

This is the following code i use to transfer the data:

Code:
Me.Bound_QtyPotted.Value = Me.Txt_QtyPotted.Value
Me.Bound_YieldPer.Value = Me.Txt_YieldPer.Value
Me.Bound_YieldQty.Value = Me.Txt_YieldQty.Value
Me.Bound_DiscPots.Value = Me.Txt_DiscPots.Value
Me.Bound_DiscUnits.Value = Me.Txt_DiscUnits.Value
Me.Bound_PredictedLoss.Value = Me.Txt_PredictedLoss.Value
Me.Bound_MixBatchNo.Value = Me.Txt_MixBatchNo.Value

If i have entered 95% in the unbound txtbox it reads as 0.95 as i toggle through the code but the bound_yieldper becomes 1 rather than 0.95.

Both textboxes are formatted as percentage. The bound field I have tried as an integer with format % and get the result of "1". I have tried it as a decimal formatted as a percentage and get the result of "0". No idea why this is not working like all other textboxes.

Any help would be great
An integer field is just that, an integer, no decimal places?

 
Why are you entering data into unbound controls? Do you not know that you have complete control over whether a changed record gets saved or not? You would validate the data in the form's BeforeUpdate event and if the data is not valid, you would cancel the save and give the user an error message to help him fix the problem.
Code:
If IsDate(Me.txtDOB) and Me.txtDOB >= Date() -65 Then
Else
    Msgbox "Employee must be less than 65 years old.", vbOKOnly
    Me.txtDOB.SetFocus
    Cancel = True
    Exit Sub
End If

If Me.txtLastName & "" = "" Then
    Msgbox "Last Name is required.", vbOKOnly
    Me.txtLastName.SetFocus
    Cancel = True
    Exit Sub
End If

.....
 

Users who are viewing this thread

Back
Top Bottom