View Full Version : Bypassing Events


aziz rasul
06-19-2006, 08:41 AM
What code can I write behind a command button on a form to bypass the On Open event of a report before opening the report?

RuralGuy
06-19-2006, 09:01 AM
What are you trying to achieve with the report?

aziz rasul
06-19-2006, 09:39 AM
I'm trying to create reports (using the SAME report) but with different criteria, hence the use of !VarianceRange. When the report is in print preview, I then want to export as a SNP file. These SNP files are accumulated on my drive ready to send in an email.

RuralGuy
06-19-2006, 10:10 AM
I don't think the OpenArgs argument of the OpenReport was implemented until acXP but you can certainly reach back to your opening form for details to run the report through the Forms collection.

aziz rasul
06-19-2006, 11:16 AM
I'm using the 2002 version which is XP.

How do I use the OpenArgs property.

RuralGuy
06-19-2006, 11:33 AM
It is the 6th argument of the OpenReport command and you simply pass a string there. You can actually pass as many arguments as you like by separating them with a delimiter such as a ";" but it is only one string. You can fetch the OpenArgs argument in the Open event of the form and use it as you wish. Here's sample code to store multiple parameters passed in the OpenArgs argument:
Private Sub Report_Open(Cancel As Integer)
Dim Args As Variant

If Not IsNull(Me.OpenArgs) Then
'-- Report is being opened from a form passing Arguments
Args = Split(Me.OpenArgs, ";")
Me.txtFirstArg = Args(0)
Me.txtSecondArg= Args(1)
End If
End Sub

aziz rasul
06-21-2006, 01:28 AM
Thanks RuralGuy. I will try that.