Log in

View Full Version : [SOLVED:] help with on click event



TonC
10-14-2024, 08:54 AM
Hello

I have a report, I opened in designview. When I click close report

The mainform will appear. In that mainform there is command button with a click event.
Private Sub lblFilterUit_Click()


Now I wanted to know, when I click in the report “Close designview” the report is closing. My mainform appears and then I need the code (which in report or form) that perform automatically the click event.
Private Sub lblFilterUit_Click()


Hope somebody can help me.


Greetings ahc,

xps350
10-14-2024, 01:13 PM
Use the on close event of the report.

Private Sub Report_Close()
'do whatever you want to do
End Sub

TonC
10-14-2024, 02:46 PM
Hello,
What do you mean
do whatever you want ? Is there no code follow up?

I don’t understand.



greetings ahc,

arnelgp
10-14-2024, 09:23 PM
on design view (from Navigation pane), no Report Event takes place.

TonC
10-15-2024, 12:03 AM
Okay,, Is there a code that works in reportview?

arnelgp
10-15-2024, 04:30 AM
it will work on Report View.
First make the click event of the label as Public not Private, example:


Public Sub lblFilterUit_Click()
MsgBox "You Invoked the Click event of Label lblFilterUit!"
End Sub

on the Close event of your Report, add this code:


Private Sub Report_Close()
DoCmd.OpenForm "MainForm"
CallByName Forms("MainForm"), "lblFilterUit_Click", VbMethod
End Sub

TonC
10-15-2024, 04:55 AM
hello arnelgp,

Its working :yes thank you

Tonc

arnelgp
10-15-2024, 04:59 AM
:thumb