Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with code On Open event.

Status
Not open for further replies.

topgun64

IS-IT--Management
Feb 5, 2008
6
US
I am having problems with the code below. I have this set on the OnOpen event of the form. But it is not working.
I know it is probally something easy I am just not seeing it...

Private Sub Form_Open(Cancel As Integer)
If Payee = "HR Electric" And Date = "JAN" Or "FEB" Then
Feb1.BackColor = vbGreen
Else
Feb1.BackColor = vbWhite
End If

End Sub
 
Thanks for the reply.

No it does not. When I try to open the form I get a type mismatch error message
 
I believe you need to use me.feb1.Backcolor= also try using the number code for the color
 
The problem is within this line. If I take out the highlighted area it works.

If Payee = "HR Electric" And Date = "JAN" [blue]Or "FEB"[/blue] Then



 
How about:

If Payee = "HR Electric" And (Date = "JAN" Or Date="FEB") Then
 
Excellent! it worked... thank you so much
 
I suggest you don't use "Date" as a variable, as it is a reserved word.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top