Errors and Crashing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Every once in a while when I'm writing some new code, I debug, save and then
switch over to the form I'm working on. When I attempt to run the program,
however, I get caught in some error loop. The first thing I get is an error
msgbox stating, "Object doesn't support this property or method." Then there
will be a blank msgbox with just an "OK" command. This is followed by a
third box that says "Resume without error." The final two msgboxes loop
infinitely. This happens often, but the most recent example came during the
load sequence of a form. The code where it occurs follows:

For x = 0 To numSub - 1
Topic(x).Visible = True
Topic(x).Caption = DLookup("[Topic Name]", "tblTopic",
"[Subject] = 'Cardiology' AND [Topic Number] = " & (x + 1) & "")
Med(x).Visible = True
Path(x).Visible = True
Pharm(x).Visible = True

TotalM = UMed(x).Caption + RMed(x).Caption
Med(x).Caption = UMed(x).Caption & "/" & TotalM

TotalP = UPath(x).Caption + RPath(x).Caption
Path(x).Caption = UPath(x).Caption & "/" & TotalP

TotalH = UPharm(x).Captino + RPharm(x).Caption
Pharm(x).Caption = UPharm(x).Caption & "/" & TotalH

UserM = UMed(x).Caption
UserP = UPath(x).Caption
UserH = UPharm(x).Caption

If UserM > TotalM Then
Med(x).ForeColor = 255
End If

If UserP > TotalP Then
Path(x).ForeColor = 255
End If

If UserH > TotalH Then
Pharm(x).ForeColor = 255
End If
Next
Case "Pulmonary Exam"
lblSuba.Caption = Forms![GenExam]!lblSub1Q.Caption
txtSuba = Forms![GenExam]!txtSub1Q
numSub = DCount("Subject", "tblTopic", "Subject = 'Pulmonary'")
Column2 numSub
For x = 0 To numSub - 1
Topic(x).Visible = True
Topic(x).Caption = DLookup("[Topic Name]", "tblTopic",
"[Subject] = 'Pulmonary' AND [Topic Number] = " & (x + 1) & "")
Med(x).Visible = True
Path(x).Visible = True
Pharm(x).Visible = True
TotalM = UMed(x).Caption + RMed(x).Caption
Med(x).Caption = UMed(x).Caption & "/" & TotalM

TotalP = UPath(x).Caption + RPath(x).Caption
Path(x).Caption = UPath(x).Caption & "/" & TotalP

TotalH = UPharm(x).Captino + RPharm(x).Caption
Pharm(x).Caption = UPharm(x).Caption & "/" & TotalH

UserM = UMed(x).Caption
UserP = UPath(x).Caption
UserH = UPharm(x).Caption

If UserM > TotalM Then
Med(x).ForeColor = 255
End If

If UserP > TotalP Then
Path(x).ForeColor = 255
End If

If UserH > TotalH Then
Pharm(x).ForeColor = 255
End If
Next

Not sure if anyone can follow all that, but most importantly I just want to
know if there is any way to stop that error message loop from occurring so I
don't have to shut down the program every time. Also, if anyone has had
similar experiences and knows a quick line of code or two that prevents this
from happening, I would be greatly obliged.

Thank you,

Joe
 
Joe,

Why not add an error handler, so you can effectively handle the error.
Also where is the first instance of an error occuring in the code below?

Dan

Joe said:
Every once in a while when I'm writing some new code, I debug, save and then
switch over to the form I'm working on. When I attempt to run the program,
however, I get caught in some error loop. The first thing I get is an error
msgbox stating, "Object doesn't support this property or method." Then there
will be a blank msgbox with just an "OK" command. This is followed by a
third box that says "Resume without error." The final two msgboxes loop
infinitely. This happens often, but the most recent example came during the
load sequence of a form. The code where it occurs follows:

For x = 0 To numSub - 1
Topic(x).Visible = True
Topic(x).Caption = DLookup("[Topic Name]", "tblTopic",
"[Subject] = 'Cardiology' AND [Topic Number] = " & (x + 1) & "")
Med(x).Visible = True
Path(x).Visible = True
Pharm(x).Visible = True

TotalM = UMed(x).Caption + RMed(x).Caption
Med(x).Caption = UMed(x).Caption & "/" & TotalM

TotalP = UPath(x).Caption + RPath(x).Caption
Path(x).Caption = UPath(x).Caption & "/" & TotalP

TotalH = UPharm(x).Captino + RPharm(x).Caption
Pharm(x).Caption = UPharm(x).Caption & "/" & TotalH

UserM = UMed(x).Caption
UserP = UPath(x).Caption
UserH = UPharm(x).Caption

If UserM > TotalM Then
Med(x).ForeColor = 255
End If

If UserP > TotalP Then
Path(x).ForeColor = 255
End If

If UserH > TotalH Then
Pharm(x).ForeColor = 255
End If
Next
Case "Pulmonary Exam"
lblSuba.Caption = Forms![GenExam]!lblSub1Q.Caption
txtSuba = Forms![GenExam]!txtSub1Q
numSub = DCount("Subject", "tblTopic", "Subject = 'Pulmonary'")
Column2 numSub
For x = 0 To numSub - 1
Topic(x).Visible = True
Topic(x).Caption = DLookup("[Topic Name]", "tblTopic",
"[Subject] = 'Pulmonary' AND [Topic Number] = " & (x + 1) & "")
Med(x).Visible = True
Path(x).Visible = True
Pharm(x).Visible = True
TotalM = UMed(x).Caption + RMed(x).Caption
Med(x).Caption = UMed(x).Caption & "/" & TotalM

TotalP = UPath(x).Caption + RPath(x).Caption
Path(x).Caption = UPath(x).Caption & "/" & TotalP

TotalH = UPharm(x).Captino + RPharm(x).Caption
Pharm(x).Caption = UPharm(x).Caption & "/" & TotalH

UserM = UMed(x).Caption
UserP = UPath(x).Caption
UserH = UPharm(x).Caption

If UserM > TotalM Then
Med(x).ForeColor = 255
End If

If UserP > TotalP Then
Path(x).ForeColor = 255
End If

If UserH > TotalH Then
Pharm(x).ForeColor = 255
End If
Next

Not sure if anyone can follow all that, but most importantly I just want to
know if there is any way to stop that error message loop from occurring so I
don't have to shut down the program every time. Also, if anyone has had
similar experiences and knows a quick line of code or two that prevents this
from happening, I would be greatly obliged.

Thank you,

Joe
 
Back
Top