GolferJohn
Technical User
This must be a simple problem, but is driving me mad!! (I am a newbie, as you can guess).
I have a form 'Stocks' with an unbound textbox 'ShareBal' and two bound textboxes 'IOwn' and 'OpenOrder', filled by the following code which calculates values from my transactions in the 1 to many child table 'purchases'.
ShareBal = DSum("Bshares", "purchases", "Purchases!StockName = Forms!Rollbacks!StockName" - DSum("Sshares", "purchases", "Purchases!StockName = Forms!Rollbacks!StockName"
If ShareBal > 0 Then
Forms!Rollbacks.IOwn = "Y"
Else
Forms!Rollbacks.IOwn = "N"
End If
If DSum("BidOffer", "purchases", "Purchases!StockName = Forms!Rollbacks!StockName" > 0 Then
Forms!rollbacks.OpenOrder = "Y"
Else
Forms!rollbacks.OpenOrder = "N"
End If
the code correctly populates the textboxes, but when I get to the end of file it also populates the blank record, which I cannot move off, since it has nothing in the key field. I have tried nesting the above code in the following:
If Not StockName = "" Then
End If
and this allows me to get off the last record, because it puts nothing in the boxes at all.
I have also tried
If StockName <> "" Then....
If Not IsNull(StockName) Then ....
both of which compile, but do not populate the textboxes.
If Not (EOF) Then ....
will not compile.
What code will correctly populate my textboxes, but not the last 'dummy' record??
Thanks for any suggestions.
John
I have a form 'Stocks' with an unbound textbox 'ShareBal' and two bound textboxes 'IOwn' and 'OpenOrder', filled by the following code which calculates values from my transactions in the 1 to many child table 'purchases'.
ShareBal = DSum("Bshares", "purchases", "Purchases!StockName = Forms!Rollbacks!StockName" - DSum("Sshares", "purchases", "Purchases!StockName = Forms!Rollbacks!StockName"
If ShareBal > 0 Then
Forms!Rollbacks.IOwn = "Y"
Else
Forms!Rollbacks.IOwn = "N"
End If
If DSum("BidOffer", "purchases", "Purchases!StockName = Forms!Rollbacks!StockName" > 0 Then
Forms!rollbacks.OpenOrder = "Y"
Else
Forms!rollbacks.OpenOrder = "N"
End If
the code correctly populates the textboxes, but when I get to the end of file it also populates the blank record, which I cannot move off, since it has nothing in the key field. I have tried nesting the above code in the following:
If Not StockName = "" Then
End If
and this allows me to get off the last record, because it puts nothing in the boxes at all.
I have also tried
If StockName <> "" Then....
If Not IsNull(StockName) Then ....
both of which compile, but do not populate the textboxes.
If Not (EOF) Then ....
will not compile.
What code will correctly populate my textboxes, but not the last 'dummy' record??
Thanks for any suggestions.
John