Bug?... Load Event Executes Twice, Open Event Does Not Execute...

G

Guest

I am opening a form using "DoCmd.OpenForm" from a command button's click
event within another open form. The form I am opening is unbound (no record
source) and is simply an input form (one textbox and one combo box) for a
couple pieces of missing information that the user will supply.

I noticed something odd happening with the form so I introduced a msgbox
prompt into the open and load events of the input form. From the prompts I
was able to determine that the open event did not execute and the load event
executed twice. Is this a bug? (This also happens occasionally with most of
my reports)

Any suggestions on a work around or a better approach would be greatly
appreciated.

Thank you,
bdl1973
 
G

Guest

What version of Acces are you using?

Are you sure that the form is Unbound?

What else are you doing?

Have you made a mistake?

I've never seen behaviour like this on an unbound form. (You
can get some odd behaviour if you are bound to an empty
recordset, or if you play with the bindings in the Open event).

Decompile and compact the mdb, try again with a new form.

(david)
 
G

Guest

Thank you for responding and my apologies for the delay in my response. I
have been away on holidays.

1) I am using MS Access 2003 from Office Professional 2003.
2) I presume a form with an empty string as the record source is deemed as
unbound.
3) The following is the code that executes when the command button on the
primary form is clicked:

Private Sub cmdPrintPO_Click()
On Error Resume Next
DoCmd.OpenForm "frmPrinter", acNormal, , , acFormPropertySettings
End Sub

4) The following is the code that executes on the Load event for the
"frmPrinter" form:

Private Sub Form_Load()
On Error Resume Next
Dim prn As Printer
For Each prn In Application.Printers
Me.cboPrinters.AddItem prn.DeviceName
Next
Me.cboPrinters.Value = DefaultPrinterStr
Me.txtCopies.Value = 1
End Sub

5) The reasoning behind the "frmPrinter" form is to allow the user to
direct which network printer his/her PO is sent to. When the user clicks the
"Ok" command button on the form another custom function is invoked and the
desired printer and number of copies are passed to that procedure. The form
is closed once the custom function has completed its operations.

Please let me know if this sufficiently answers your questions. I will also
try inserting a new form after decompile and compact & repair.

Thank you,
bdl1973
 
G

Guest

I don't have 2003 loaded, and won't be able to test for
another week.

You appear to be making a 'design' change to the form,
so I'm guessing that is causing the unusual behaviour. The
form re-loads after the printer property is changed.

You should get rid of On Error Resume Next. If you have
any errors, you want to see them. Hidden errors are often
the cause of unexplained behaviour.

You don't seem to be using the open event, so that is not
an issue. On the basis of the code you have shown, there
is no reason to care if the Load event fires twice.

(david)
 
G

Guest

Thank you for your help and suggestions so far.

When you mentioned that it appeared as though I was making a design change
to the form you were partially correct. I am actually referencing one of the
forms properties prior to using the OpenForm method. I had left out that
piece of code from my original post to help keep the post short and I should
not have for I am certain you would have caught it as my problem right away.
My debugging and troubleshooting skills are a little dull and I sometimes
forget some of the basic principles of OOP. I have changed my approach and
the form behaves normally now. (Open event still doesn't fire although I
believe that is because the form is not bound to a record source.)

Thank you very much for your assistance. Your suggestions and feedback were
most helpful. (Bug?... not a bug just my inexperience)

Brad
 

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

Similar Threads

Form load event 1
FORM ACTIVATE EVENT 3
On Load Event 3
Not in list event 5
Form On Open event, except not exactly 4
Resize Event triggered twice 1
Form Load Event Occurs Twice 2
Strange event behavior? 4

Top