Dan Waters
dwaters at usinternet.com
Mon Jul 21 08:32:41 CDT 2003
Dave, I also have situations where I don't want to run the Current event more than once, and I use a code technique similar to what's below: 1) Create a module boolean variable: Dim MblnRunCurrent as Boolean 2) Add this code at the beginning of the Current event: If MblnRunCurrent = False Then MblnRunCurrent = True Exit Sub End If When your form is first opened, any boolean variable have a False value. So, when the Current event is triggered the first time, the code shown above will prevent the remaining code from operating. The next time the Current event is triggered, the boolean variable is True, and the remaining code in the Current event will now run. Hope this helps, Dan Waters -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of David Emerson Sent: Sunday, July 20, 2003 7:04 PM To: dba-SQLServer at databaseadvisors.com; ACCESS-L at PEACH.EASE.LSOFT.COM; accessd at databaseadvisors.com Subject: [AccessD] Recordsource running before Open Event Groups, I have the following code in the Open event of a form - If Me.OpenArgs <> "All" Then Me.InputParameters = Me.OpenArgs <- Form_Current event triggers here Me.RecordSource = "spfrmGeneralJournal" Else Me.RecordSource = "spfrmGeneralJournal" End If The problem is that the "Me.InputParameters = Me.OpenArgs" triggers the Form's Current event. This is a problem because in there it checks for the value of a field and because the Recordsource hasn't been defined yet it generates an error. The reason that the record source is not defined until in the Open Event is because the front end is linked to an SQL B/E and the table that is the source has over 55,000 records which is taking over 5 seconds to open. This is opened, then the Open event is fired to produce the reduced record set (in effect the sproc is being run twice). Does anyone have a method for opening the form without the Current event being triggered before the open event is completed? (Or preventing the sproc being run before the Open event is processed)? Regards David Emerson DALYN Software Ltd 25b Cunliffe St, Johnsonville Wellington, New Zealand Ph/Fax (877) 456-1205 _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com