Close a query and reopen the form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I"m not sure where to post this but here's what I'm trying to do. I created a
form and a query and what I want to do is, input a value into the form, the
query runs, and the form closes, then when I close the query I want the form
to reopen. I tried using the query to fill in another form and it works to
fill in the form but when I close the form it still doesn't reopen the
original input form. Can this be done easily or at all?

Thank you in advance for your help.
Joe
 
Hi Joe,
...then when I close the query I want the form to reopen.

You won't be able to do this, since a query has no events that you can
program.
I tried using the query to fill in another form and it works to
fill in the form but when I close the form it still doesn't reopen the
original input form. Can this be done easily or at all?

Sure. In the Form_Close event procedure for the second form, use a
DoCmd.Openform statement to re-open the first form.

Private Sub Form_Close()
On Error GoTo ProcError

DoCmd.OpenForm "NameOfFirstFormGoesHere", View:=acNormal

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure Form_Close..."
Resume ExitProc
End Sub


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
Tom,
Thank you it worked perfectly.

Joe

Tom Wickerath said:
Hi Joe,


You won't be able to do this, since a query has no events that you can
program.


Sure. In the Form_Close event procedure for the second form, use a
DoCmd.Openform statement to re-open the first form.

Private Sub Form_Close()
On Error GoTo ProcError

DoCmd.OpenForm "NameOfFirstFormGoesHere", View:=acNormal

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure Form_Close..."
Resume ExitProc
End Sub


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 

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

Back
Top