- Local time
- Today, 06:45
- Joined
- Feb 28, 2001
- Messages
- 28,693
I've been out of town for a family function so just got back now. I see that Josef P. already asked a question I would have asked. But I'll rephrase it into a comment.
When you use a continuous form (and it appears that you did exactly that), there is only one row, only one set of controls. Access re-uses the form for each row that it displays. So if you click on a text box you have to first determine WHICH row you just selected - because technically, you are selecting the same control no matter which row you click in. Your complaint that you sometimes get the wrong row is because you are somehow being careless with record selection. Given this problem, I suspect that your previously described issue with that loop is partly because you are not properly clearing alarms anyway, so they don't go away. I don't see where you are obtaining record information regarding WHICH row you are currently examining, but with a backlog of events, you have to remember that multiple events CAN fire without regard to which record is currently selected. That will be part of the confusion. Look up .RecordSelector and understand that your code cannot presume that the current record (on the form) is the one that triggered the alarm. You need to convert some of this to use action queries to UPDATE certain fields to zero in the record you just clicked, which first involves determining the record number and then determining the PK of the table holding the continuously displayed data. Search around in the forum for more on the subject of continuous forms.
Gasman's comment is relevant to this because you can end up in a complex subroutine with code that uses two different spellings of what should be the same variable. But using Option Explicit or checking that Tools/Options setting would help a lot to avoid that. The setting IS slightly a pain in the toches because it requires you to DIM every variable, but it catches every case where you mistyped a name.
When you use a continuous form (and it appears that you did exactly that), there is only one row, only one set of controls. Access re-uses the form for each row that it displays. So if you click on a text box you have to first determine WHICH row you just selected - because technically, you are selecting the same control no matter which row you click in. Your complaint that you sometimes get the wrong row is because you are somehow being careless with record selection. Given this problem, I suspect that your previously described issue with that loop is partly because you are not properly clearing alarms anyway, so they don't go away. I don't see where you are obtaining record information regarding WHICH row you are currently examining, but with a backlog of events, you have to remember that multiple events CAN fire without regard to which record is currently selected. That will be part of the confusion. Look up .RecordSelector and understand that your code cannot presume that the current record (on the form) is the one that triggered the alarm. You need to convert some of this to use action queries to UPDATE certain fields to zero in the record you just clicked, which first involves determining the record number and then determining the PK of the table holding the continuously displayed data. Search around in the forum for more on the subject of continuous forms.
Gasman's comment is relevant to this because you can end up in a complex subroutine with code that uses two different spellings of what should be the same variable. But using Option Explicit or checking that Tools/Options setting would help a lot to avoid that. The setting IS slightly a pain in the toches because it requires you to DIM every variable, but it catches every case where you mistyped a name.