Which Event do I need?

G

Guest

I want to run some code every time the user switches between records. I know
I can use the Load event for when the form is loaded, but what about when
the user switches between records?

Thanks,

Shon
 
W

Wayne Morgan

Use the Form's OnCurrent event. The OnCurrent event also fires when you go to the first
record as the form loads.
 
G

Guest

I've tried using the following code. However, it is not working when I
change records using the navigation tools found at the bottom of the form.

Private Sub Form_OnCurrent()
If Approved.Value = True Then
RESPADocsDate.Enabled = True
DateClosed.Enabled = False
TurnDownDate.Enabled = False
Else
RESPADocsDate.Enabled = False
DateClosed.Enabled = True
TurnDownDate.Enabled = True
End If
End Sub

Thanks,

Shon
 
R

R. Hicks

What you posted should work .. although all you need is this:

Private Sub Form_OnCurrent()
Me.RESPADocsDate.Enabled = Me.Approved
Me.DateClosed.Enabled = Not Me.Approved
Me.TurnDownDate.Enabled = Not Me.Approved
End Sub

RD
 
A

Andrew Smith

Open the form's property sheet, find the On Current event and check that it
shows "[Event Procedure]"

If it does then add some MsgBox or Debug.Print statements to your code to
check the values of some of these items, eg put Debug.Print "Approved.Value
= " & Approved.Value and see if you get the result you're expecting.
 
W

Wayne Morgan

Try Andrew's suggestions. What "isn't working"? Do you know if the code is running and
just not doing what you want, are you getting any error messages? Are your control names
and field names the same? If so, change the control names.

Example
Field Name: Approved
Control Name: chkApproved

Field Name: DateClosed
Control Name: txtDateClosed
 
G

Graham Mandeno

Hi Shon

The *event* is called "Current", not "OnCurrent", so your event procedure
should be:
Private Sub Form_Current()

The OnCurrent *property* specifies the action to be performed when the
Current *event* is raised. So in the form's property sheet, you should have
[Event Procedure] in the "On Current" cell.
 

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