I am a newbie and can't decide what I'm doing wrong.
Code:
refsql = "select Quantity_owned, Current_Val, symbol, Dont_record from [Stock_Data]" 'Fields(0) = Quanity, Fields(1)= Current Value, field(2) = symbol
Set rstStkD = CurrentDb.OpenRecordset(refsql, dbOpenDynaset)
C = 0
cv = 0 'Current Value
Tot = 0 'Total
s = "S" 'Symbol
rstStkD.MoveFirst
Do While Not rstStkD.EOF
'If (rstStkD.Fields(3)) = -1 Then
If IsNull(rstStkD.Fields(1)) Then
If rstStkD.Fields(3) = "false" Then
'Debug.Print rstStkD.Fields(3)
msg = "The current sock value is missing for " & rstStkD.Fields(2) & ". Make sure closed stock positions indicate a current value and are not deleted."
X = MsgBox(msg, vbOKOnly)
Exit Sub
End If
End If
q = rstStkD.Fields(0) 'Quanity
cv = rstStkD.Fields(1)
Tot = Tot + q * cv
s = rstStkD.Fields(2)
rstStkD.MoveNext
Loop
I wrote this as past od a DB to record activities in my portfolio. I won't to display a message when I forgot to include a particular stock. However, there are some I don't won't to display. Field three is a check box. When checked I don't want Access to record the information. However, if the name is missing and the box is checked, Access kicks me out of the loop with out continuing to record the rest of the data. Everything seems to work until it reaches the "Tot = Tot + q * cv" statement. Again, this only happens when the box is checked and the name is missing. Any other combination seems to work!
Thanks for your help. You people are great!!
Bill
Code:
refsql = "select Quantity_owned, Current_Val, symbol, Dont_record from [Stock_Data]" 'Fields(0) = Quanity, Fields(1)= Current Value, field(2) = symbol
Set rstStkD = CurrentDb.OpenRecordset(refsql, dbOpenDynaset)
C = 0
cv = 0 'Current Value
Tot = 0 'Total
s = "S" 'Symbol
rstStkD.MoveFirst
Do While Not rstStkD.EOF
'If (rstStkD.Fields(3)) = -1 Then
If IsNull(rstStkD.Fields(1)) Then
If rstStkD.Fields(3) = "false" Then
'Debug.Print rstStkD.Fields(3)
msg = "The current sock value is missing for " & rstStkD.Fields(2) & ". Make sure closed stock positions indicate a current value and are not deleted."
X = MsgBox(msg, vbOKOnly)
Exit Sub
End If
End If
q = rstStkD.Fields(0) 'Quanity
cv = rstStkD.Fields(1)
Tot = Tot + q * cv
s = rstStkD.Fields(2)
rstStkD.MoveNext
Loop
I wrote this as past od a DB to record activities in my portfolio. I won't to display a message when I forgot to include a particular stock. However, there are some I don't won't to display. Field three is a check box. When checked I don't want Access to record the information. However, if the name is missing and the box is checked, Access kicks me out of the loop with out continuing to record the rest of the data. Everything seems to work until it reaches the "Tot = Tot + q * cv" statement. Again, this only happens when the box is checked and the name is missing. Any other combination seems to work!
Thanks for your help. You people are great!!
Bill