Which Event do I need?

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Use the Form's OnCurrent event. The OnCurrent event also fires when you go to the first
record as the form loads.
 
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
 
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
 
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.
 
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
 
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.
 
Back
Top