code causing db to crash

R

Rick

I have a user who is working with Access97. He said that
recently when he runs the following piece of code he gets
the following error- runtime error - "62506"

The code which he said was not changed and ran fine before
is:
Here is the code


Private Sub Detail1_Format(Cancel As Integer, FormatCount
As Integer)

If [Project Days Variance] < 0 Then
[Project Days Variance].BackColor = 0
[Project Days Variance].ForeColor = 16777215
Else
[Project Days Variance].BackColor = 16777215
[Project Days Variance].ForeColor = 0
End If

If [Dev Cost Variance] < 0 Then
[Dev Cost Variance].BackColor = 0
[Dev Cost Variance].ForeColor = 16777215
Else
[Dev Cost Variance].BackColor = 16777215
[Dev Cost Variance].ForeColor = 0
End If

End Sub

If anyone can figure out why this code is no longer
working, I would appreciate it very much! Please e-mail
me at (e-mail address removed)
 
B

Brendan Reynolds \(MVP\)

I'd first try it this way ...

Const conTheColor As Long = 1677215

Dim ctlPDV As Control
Dim ctlDCV As Control

Set ctlPDV = Me![Project Days Variance]
Set ctlDCV = Me![Dev Cost Variance]

With ctlPDV
If .Value < 0 Then
.BackColor = 0
.ForeColor = conTheColor
Else
.BackColor = conTheColor
.ForeColor = 0
End If
End With

.... etc. for the second control.

If I still got the error after that, I'd begin to suspect corruption, and
try importing everything into a new, empty MDB.
 
T

Tom Wickerath

Hi Rick,

The first thing you should check for, when code that used to work is no longer working, is
a missing reference. Doug Steele has a pretty good paper on this topic:

http://members.rogers.com/douglas.j.steele/AccessReferenceErrors.html

Tom
_____________________________________


I have a user who is working with Access97. He said that
recently when he runs the following piece of code he gets
the following error- runtime error - "62506"

The code which he said was not changed and ran fine before
is:
Here is the code


Private Sub Detail1_Format(Cancel As Integer, FormatCount
As Integer)

If [Project Days Variance] < 0 Then
[Project Days Variance].BackColor = 0
[Project Days Variance].ForeColor = 16777215
Else
[Project Days Variance].BackColor = 16777215
[Project Days Variance].ForeColor = 0
End If

If [Dev Cost Variance] < 0 Then
[Dev Cost Variance].BackColor = 0
[Dev Cost Variance].ForeColor = 16777215
Else
[Dev Cost Variance].BackColor = 16777215
[Dev Cost Variance].ForeColor = 0
End If

End Sub

If anyone can figure out why this code is no longer
working, I would appreciate it very much! Please e-mail
me at (e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Two VB Codes for changing conditions 3
Versioning Issue 3
using more than one detail record in one line on report 2
Annual Calendar 1
Code 1
Format Question 1
AfterUpdate 5
Make a variable text box flash red 4

Top