Hi,
Firstly thanks in advance for looking at this. I am quite new to VBA...
I have VBA code which looks up a price based on a customer and part field of a table...
The result always rounds up or down to the nearest whole number, I need to show 2 dec places for currency...
Any help, thanks
The code is.......
Private Sub PartNo_AfterUpdate()
Dim sSQL As String
Dim Rec As Recordset
Dim db As Database
' Query to bring out the price, using variables in the form.
sSQL = "SELECT DISTINCT price FROM tblPrices "
sSQL = sSQL & "WHERE partno = '" & PartNo & "' AND CustID = '" & CustID & "';"
Set db = CurrentDb
Set Rec = db.OpenRecordset(sSQL)
' Check something is returned and set the price field to returned value.
If Rec.RecordCount > 0 Then
price = Rec("price"
Else
price = "0"
End If
Me.Requery
End Sub
Firstly thanks in advance for looking at this. I am quite new to VBA...
I have VBA code which looks up a price based on a customer and part field of a table...
The result always rounds up or down to the nearest whole number, I need to show 2 dec places for currency...
Any help, thanks
The code is.......
Private Sub PartNo_AfterUpdate()
Dim sSQL As String
Dim Rec As Recordset
Dim db As Database
' Query to bring out the price, using variables in the form.
sSQL = "SELECT DISTINCT price FROM tblPrices "
sSQL = sSQL & "WHERE partno = '" & PartNo & "' AND CustID = '" & CustID & "';"
Set db = CurrentDb
Set Rec = db.OpenRecordset(sSQL)
' Check something is returned and set the price field to returned value.
If Rec.RecordCount > 0 Then
price = Rec("price"
Else
price = "0"
End If
Me.Requery
End Sub