Setting properties upon paging through records in single form view

K

Kathy Webster

I have a wonderful macro that determines visibility of certain fields
depending on the value of another field in the record called [region]. The
macro runs when the single form opens.

I need to have the visibility macro re-execute every time I press page down
in the singe form view, because paging down displays the next record, which
may need different fields to be visible depending on the [region] of the
next record.

Thanks in advance,
Kathy
 
D

Douglas J. Steele

Set the form's KeyPreview property to True (Yes), then put code in the
form's OnKeyDown event:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 34 Then
' call your macro here
End If
End Sub
 
K

Kathy Webster

Will that work if the user clicks the next record indicator as well as
pressing page down?

Douglas J. Steele said:
Set the form's KeyPreview property to True (Yes), then put code in the
form's OnKeyDown event:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 34 Then
' call your macro here
End If
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Kathy Webster said:
I have a wonderful macro that determines visibility of certain fields
depending on the value of another field in the record called [region]. The
macro runs when the single form opens.

I need to have the visibility macro re-execute every time I press page
down in the singe form view, because paging down displays the next
record, which may need different fields to be visible depending on the
[region] of the next record.

Thanks in advance,
Kathy
 
D

Douglas J. Steele

No, it won't. It's only checking for keyboard input.

But hold on. I assumed you were using Page Down on a large form to get to
another part of the form for the same record. If what you want is to run the
macro whenever the record changes, all you have to do is put the call in the
form's OnCurrent event: that fires every time the record changes.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Kathy Webster said:
Will that work if the user clicks the next record indicator as well as
pressing page down?

Douglas J. Steele said:
Set the form's KeyPreview property to True (Yes), then put code in the
form's OnKeyDown event:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 34 Then
' call your macro here
End If
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Kathy Webster said:
I have a wonderful macro that determines visibility of certain fields
depending on the value of another field in the record called [region].
The macro runs when the single form opens.

I need to have the visibility macro re-execute every time I press page
down in the singe form view, because paging down displays the next
record, which may need different fields to be visible depending on the
[region] of the next record.

Thanks in advance,
Kathy
 
K

Kathy Webster

Yowzah! Exactly what I was looking for! Tx.

Douglas J. Steele said:
No, it won't. It's only checking for keyboard input.

But hold on. I assumed you were using Page Down on a large form to get to
another part of the form for the same record. If what you want is to run
the macro whenever the record changes, all you have to do is put the call
in the form's OnCurrent event: that fires every time the record changes.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Kathy Webster said:
Will that work if the user clicks the next record indicator as well as
pressing page down?

Douglas J. Steele said:
Set the form's KeyPreview property to True (Yes), then put code in the
form's OnKeyDown event:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 34 Then
' call your macro here
End If
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I have a wonderful macro that determines visibility of certain fields
depending on the value of another field in the record called [region].
The macro runs when the single form opens.

I need to have the visibility macro re-execute every time I press page
down in the singe form view, because paging down displays the next
record, which may need different fields to be visible depending on the
[region] of the next record.

Thanks in advance,
Kathy
 

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