Close Form and requery?

D

Doug_C

Hello,

I am working on an FAQ Database that has a main form to view all entries
made. On the main form is a button to open a secondary form for inputting the
information. Everything seems to work fine except:

When I click the close button, I get this error message:
"The expression you entered refers to an object that is closed or doesn't
exist".
Here is the code in the button:
Private Sub Close_Form_Click()
On Error GoTo Err_Close_Form_Click

DoCmd.Close
Me!FAQ.Form.Requery

Exit_Close_Form_Click:
Exit Sub

Err_Close_Form_Click:
MsgBox Err.Description
Resume Exit_Close_Form_Click
End Sub

Also from the main form, when I click on the button to open the new form how
do I get the cursor to start in the subject field rather than the text field?

I am still a novice so please simplify answer. I'm sure I am missing
something so any help would be most appreciated!!

Thanks!
 
L

Lolik

are you trying to requery the same form you've just closed?
Why would you want to requery a form you are closing then?

To set focus to the the field of your choice,
in form Design mode open new form's properties,
click on Events tab, find OnOpen, expand the combo box,
select [Event Procedure], click on the "..." button,
and in the VBA editor window add:

name_of_your_subject_field.setfocus

that should do the trick...
 
D

Doug_C

Hi Lolik,

I did the set focus and it worked fine. Yes, it doesn't make sense to
requery a closing form so I am requerying the main form. Thank you very much
for your help and insight which made me think more about what I am doing.

Lolik said:
are you trying to requery the same form you've just closed?
Why would you want to requery a form you are closing then?

To set focus to the the field of your choice,
in form Design mode open new form's properties,
click on Events tab, find OnOpen, expand the combo box,
select [Event Procedure], click on the "..." button,
and in the VBA editor window add:

name_of_your_subject_field.setfocus

that should do the trick...


Doug_C said:
Hello,

I am working on an FAQ Database that has a main form to view all entries
made. On the main form is a button to open a secondary form for inputting the
information. Everything seems to work fine except:

When I click the close button, I get this error message:
"The expression you entered refers to an object that is closed or doesn't
exist".
Here is the code in the button:
Private Sub Close_Form_Click()
On Error GoTo Err_Close_Form_Click

DoCmd.Close
Me!FAQ.Form.Requery

Exit_Close_Form_Click:
Exit Sub

Err_Close_Form_Click:
MsgBox Err.Description
Resume Exit_Close_Form_Click
End Sub

Also from the main form, when I click on the button to open the new form how
do I get the cursor to start in the subject field rather than the text field?

I am still a novice so please simplify answer. I'm sure I am missing
something so any help would be most appreciated!!

Thanks!
 

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