This is my first time doing this function. Can someone tell me what I'm doing wrong?
Sub getretails()
Dim o As DAO.Recordset
Dim bot As Variant
Dim top As Variant
Set o = CurrentDb.OpenRecordset("TblRetail")
While Not o.EOF
bot = Round(o![GM%].Value, 2)
top = o![GM%].Value + 0.05
Dim cost As Variant
cost = 0
Dim x As Integer
x = 3
Dim ret As Variant
ret = 0
cost = o![Unit Net].Value
ret = cost / (1 - bot)
tempInt = ret
If (tempInt = theValue) Then 'check if original value was already whole
'do nothing
Else
tempInt = tempInt + 1 'value was not whole integer, add one to round up
End If
roundUp = tempInt 'return rounded value
ret = roundUp - 0.01
gp = (ret - cost) / ret
Do While gp > top
ret = ret - 0.1
gp = (ret - cost) / ret
Loop
CurrentDb.Execute "Update tblRetail set Retail = Round(ret, 2)"
o.MoveNext
Wend
End Sub
Sub getretails()
Dim o As DAO.Recordset
Dim bot As Variant
Dim top As Variant
Set o = CurrentDb.OpenRecordset("TblRetail")
While Not o.EOF
bot = Round(o![GM%].Value, 2)
top = o![GM%].Value + 0.05
Dim cost As Variant
cost = 0
Dim x As Integer
x = 3
Dim ret As Variant
ret = 0
cost = o![Unit Net].Value
ret = cost / (1 - bot)
tempInt = ret
If (tempInt = theValue) Then 'check if original value was already whole
'do nothing
Else
tempInt = tempInt + 1 'value was not whole integer, add one to round up
End If
roundUp = tempInt 'return rounded value
ret = roundUp - 0.01
gp = (ret - cost) / ret
Do While gp > top
ret = ret - 0.1
gp = (ret - cost) / ret
Loop
CurrentDb.Execute "Update tblRetail set Retail = Round(ret, 2)"
o.MoveNext
Wend
End Sub