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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write two "OnCurrent" events as a procedure

Status
Not open for further replies.

Clayts

Technical User
Feb 20, 2007
2
NZ
Hi, Im relatively new to writing code in VBA for Microsoft Access and have come across a slight problem.

I need to run two OnCurrent event procedures in a form I have created. I currently have:

Private Sub Form_Current()
If Me.ExpiryDate < Date Then
Me.ExpiryDate.ForeColor = vbRed
Else
Me.ExpiryDate.ForeColor = vbBlack
End If
End Sub

This is so the expiry dates in the form show up as red. However I also need the following code to run as an OnCurrent Event Procedure.

Private Sub Form_Current()
On Error Resume Next
Me![Imageframe].Picture = Me![Photo]
End Sub

This will set seperate images in my form. How do I combine both of these into One OnCurrent event?

Thanks!

 
Simply like this:
Code:
Private Sub Form_Current()
If Me!ExpiryDate < Date Then
  Me!ExpiryDate.ForeColor = vbRed
Else
  Me!ExpiryDate.ForeColor = vbBlack
End If
On Error Resume Next
Me!Imageframe.Picture = Me!Photo
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks, who knew it was that simple!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top