Help with hiding/showing forms

K

Kate

I have some code attached to a button on a form that runs
a query, hides the form and then tries to show another
form. It hides the first form, displays the result of the
query but doesn't show the second form. What am I doing
wrong?

Also how do I stop the query result displaying?

DoCmd.OpenQuery "QueryAv"

' 'Hide availability form
Forms![SINGLE BOOKING AVAILABILITY].Visible = False
' 'Open the detail form
DoCmd.OpenForm "SINGLE BOOKING DETAIL"
' '
Forms![SINGLE BOOKING DETAIL].Visible = True
 
K

KaiRich

Hi Kate,


Try opening the second form by:
DoCmd.OpenForm "frm_YourSecondForm"

And closing the first form by:
DoCmd.Close acForm, "frm_YourFirstForm"

This code is in the first form (yes?) and so when it is
closed the code stops. Therefore open the second form
before you close the first form (It happens so quickly
that the user will only see an instant change of forms).

Why are you using a form to open/show a query?
If the query is for the benefit of some list box on the
second form then write some code in the form's load event
like:
Private Sub Form_Load()
lst_YourListBox.Requery
End Sub

For the user's sake I strongly recommend that you don't
have queries popping open, build it into UserForms.

I hope this helps,
Kai
 

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