Close form

M

MarinMarinov

I hav very strange situation. In database from menu with asinged funtion i
open Form. In this form i hav DTPicker Control. In Form_Load i set value of
this control to today.If i close form from form close button everything is
ok, but if i close from the Access main window close button i recive error:
DTPicker returned the error:property is read only.
, and program close.After some experiments, i found the bug. Then i close
from Access main window the Form_Load event ocur and generate the error then
i try to set the value of DTPicker Control.
Can someone explain me why this happend. Why Form_Load event ocur?

Thanks in advance.
 
B

Barry Gilbert

Marin,
There's no reason the Form_Load event should fire when closing Access. Are
you sure you're not calling the Sub from another event? From another form?

Barry
 
M

MarinMarinov

First i forgot to say i have another form opened in backgroung. This form is
for statistics - how many records and so...(border style None, no asigned
function on Close). Then i remove this form and the problem form is alone and
i close application from main window - no problem??? I try with another form,
i open onother form, then open problem form and if i close from main window -
the same problem Load_Form event ocur and error??? I give up....
 
B

Barry Gilbert

It almost sounds like your one of the forms is being opened in Dialog view in
another's Form_Load event and that the event keeps executing after the 2nd
form is closed. Are you opening any forms in Dialog view from the Load event?

Barry
 
M

MarinMarinov

In AutoExec macros i start function Start, he load some settings from
registry, get data from onother database and start statistical form -
DoCmd.OpenForm "frmMain".
From menu with function open the problem form - DoCmd.OpenForm "frmNew".
I remove all code from frmMain (HasModule - No) and then close from Access,
same situation Load event ocur for form frmNew. This is the code in Form_Load
of frmNew(the problem form):
Private Sub Form_Load()
MsgBox "aa", vbCritical
DBegPicker.Value = Format(Now, "dd.mm.yyyy")
DEndPicker.Value = #12/31/9999#
DEndPicker.Visible = False
End Sub
MsgBox i set then look for the problem and then i close from Access window
the Message displayed on the screen. I can't understand what is wrong. How
the Load event of frmNew occur?
 
B

Barry Gilbert

MarinMarinov said:
In AutoExec macros i start function Start, he load some settings from
registry, get data from onother database and start statistical form -
DoCmd.OpenForm "frmMain".
From menu with function open the problem form - DoCmd.OpenForm "frmNew".
I remove all code from frmMain (HasModule - No) and then close from Access,
same situation Load event ocur for form frmNew. This is the code in Form_Load
of frmNew(the problem form):
Private Sub Form_Load()
MsgBox "aa", vbCritical
DBegPicker.Value = Format(Now, "dd.mm.yyyy")
DEndPicker.Value = #12/31/9999#
DEndPicker.Visible = False
End Sub
MsgBox i set then look for the problem and then i close from Access window
the Message displayed on the screen. I can't understand what is wrong. How
the Load event of frmNew occur?

Hmm. Have you looked at the call stack? Put a break in this event and click
Ctrl-L. If this is being called from another piece of code, it would show up
there.

Other than that suggestion, I'm at a loss.

Barry
 

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