access 2003 datasheet alternate row color

jdlc

Registered User.
Local time
Today, 15:24
Joined
Mar 26, 2013
Messages
56
Hi Members,

I'm hoping that you can enlightened me with this case I'm working.

I have this code to apply alternate color of my datasheet and it's working fine in my test database, but when I apply it into my production database (a split database), the out come is not consistent, as if the public variable "g_RowState" is collapsing. Btw I'm using MSA 2003.

Is it the network traffic that causes the variable misfire?

Here is the code that I used:

Code:
''\\ HOW TO...
''\\ Add a  Textbox named RS onto your form, in the ControlSource Property enter "=RowState()"
''\\ On the Form_Load Event add the following code

Private Sub Form_Load()
ResetConditions Me
SetConditions Me
End Sub
''Add a Code Module to you Project and Enter the following Code....
Public g_RowState As Long

Public Function RowState() As Long
''\\ This function sets the Rowstate switch to determine the row condition or color
If g_RowState = 0 Then g_RowState = 1 Else g_RowState = 0
RowState = g_RowState
End Function

Public Sub SetConditions(frm As Form)
''\\THE NEXT LINE WILL IGNORE CONTROLS SUCH AS LABELS AND COMMAND BUTTONS
On Error Resume Next
Dim BColor As Long
Dim ctl As Control
''\\CHANGE THE BACKGROUND COLOR ON THE NEXT LINE
BColor = 14803425 
For Each ctl In frm.Controls
With ctl.FormatConditions.Add(acExpression, acNotEqual, "[RS]")
.BackColor = BColor
End With
Next

End Sub

Public Sub ResetConditions(frm As Form)
On Error Resume Next
Dim BColor As Long
Dim ctl As Control
BColor = -2147483633
For Each ctl In frm.Controls
''\\ REMOVE PREVIOUS FORMATS
ctl.FormatConditions.Item(0).Delete
ctl.FormatConditions.Item(1).Delete
ctl.FormatConditions.Item(2).Delete
Next

End Sub
 
I found the problem, the culprit is my pop-up form message. I call this form to display a message before setting the source object of the subform control. I deactivate the procedure and replace it with a label message followed by doevents and everything is working fine.
 

Users who are viewing this thread

Back
Top Bottom