Two VB Codes for changing conditions

M

Macro Hunter

I have two VB Codes that work fine seperated, but don't work combined. How
do I combine them?

CODE:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Section(0).BackColor = vbWhite Then
Me.Section(0).BackColor = 13434828
Else
Me.Section(0).BackColor = vbWhite
End If

If InStr([Inner Hydro Operational Flights per Minute], "Unassigned") = 1 Then
[Inner Hydro Operational Flights per Minute].ForeColor = 16777215 'white
Else
[Inner Hydro Operational Flights per Minute].ForeColor = 0
End If

End Sub
 
D

Dirk Goldgar

Macro Hunter said:
I have two VB Codes that work fine seperated, but don't work combined. How
do I combine them?

CODE:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Section(0).BackColor = vbWhite Then
Me.Section(0).BackColor = 13434828
Else
Me.Section(0).BackColor = vbWhite
End If

If InStr([Inner Hydro Operational Flights per Minute], "Unassigned") = 1
Then
[Inner Hydro Operational Flights per Minute].ForeColor = 16777215 'white
Else
[Inner Hydro Operational Flights per Minute].ForeColor = 0
End If

End Sub


What do you mean by "combine"? What effect are you trying to achieve? I
see that you are toggling the Detail section's BackColor, presumably to get
a graybar effect. But what are you doing with the control?
 
M

Macro Hunter

Yes, I'm trying to get the grey bar effect (every other line having a
different back color), but I'm also needing to change the color of fields
that use the word "Unassigned" in them. So far, all I get to happen is for
either the grey bar effect doesn't work, or the field color makes it where
the rest of the row does not follow the grey bar effect.

Thanks for your interest in helping.



Dirk Goldgar said:
Macro Hunter said:
I have two VB Codes that work fine seperated, but don't work combined. How
do I combine them?

CODE:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Section(0).BackColor = vbWhite Then
Me.Section(0).BackColor = 13434828
Else
Me.Section(0).BackColor = vbWhite
End If

If InStr([Inner Hydro Operational Flights per Minute], "Unassigned") = 1
Then
[Inner Hydro Operational Flights per Minute].ForeColor = 16777215 'white
Else
[Inner Hydro Operational Flights per Minute].ForeColor = 0
End If

End Sub


What do you mean by "combine"? What effect are you trying to achieve? I
see that you are toggling the Detail section's BackColor, presumably to get
a graybar effect. But what are you doing with the control?

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 
D

Dirk Goldgar

Macro Hunter said:
Yes, I'm trying to get the grey bar effect (every other line having a
different back color), but I'm also needing to change the color of fields
that use the word "Unassigned" in them. So far, all I get to happen is for
either the grey bar effect doesn't work, or the field color makes it where
the rest of the row does not follow the grey bar effect.

I'm not sure exactly what you mean by "does not follow the grey bar effect".
However, it does seem clear that you need to ensure that the field's
ForeColor can be seen on whatever BackColor the detail section is set to.
If you're trying to print white on white, that's not going to be visible.
So, as far as the control highlighting is concerned, you need to either use
a highlight color that will show up well on both backgrounds, or else first
determine what color the detail section's BackColor is going to be, and then
decide what highlight color you want to use for the control.

Is the grey bar effect itself working, or is there a problem with that? I
can conceive of there being a problem with that, simply because it is
possible for the section's Format event to fire multiple times for one
record, depending on what lengths Access has to go to in order to decide how
to lay out the section. If that is causing difficulties for you, there's
another way to strictly alternate the row-highlighting.
 

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

Top