Access 2003 VBA LostFocus Problem

Hello, I'm using the following code to calculate price based on QTY * Price. My code works unless the user types in a value like 1.5. It appears to be rounding the value up to 2.

What am I doing wrong?

Private Sub txt_RFR_QTY1_LostFocus()
'first ensure QTY is not null and assign value
Dim myQTY As Double

If Me.txt_RFR_QTY1.Text = "" Then
Me.txt_RFR_QTY1.SetFocus
Me.txt_RFR_QTY1.Text = 0
myQTY = Me.txt_RFR_QTY1.Text
Screen.PreviousControl.SetFocus
Else
myQTY = Me.txt_RFR_QTY1.Text

End If

'get and calculate price
 Dim qdf As QueryDef
 Dim rst As Recordset
 Dim myPrice As Currency

 Set qdf = CurrentDb.QueryDefs("Get_PartPrice")

 qdf.Parameters(0) = Me.cbo_RFR_PartNumber1.Column(0)
 qdf.Parameters(1) = Me.cbo_RFR_PartNumber1.Column(0)

 Set rst = qdf.OpenRecordset

For Each fld In rst.Fields
Me.txt_RFR_PartCost1.Visible = True
      Me.txt_RFR_PartCost1.SetFocus
      myPrice = fld
      Dim TotalPrice As Currency
      TotalPrice = (myPrice * myQTY)
      
     Me.txt_RFR_PartCost1.Text = TotalPrice
  Screen.PreviousControl.SetFocus
 Me.txt_RFR_PartCost1.Visible = False
Next
 
 rst.Close
 qdf.Close
 Set rst = Nothing
 Set qdf = Nothing
End Sub

Open in new window

gogetsomeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mbizupCommented:
Check the design of the underlying table(s)...

These fields should be numeric, and under the field properties in the bottom panel in the table design view, set the Field Length to Double
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gogetsomeAuthor Commented:
Exactly! Thank you so much!!! I might pick up access vba one day soon.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.