A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Keep form open after Query command is excecuted?



 
 
Thread Tools Display Modes
  #1  
Old December 26th, 2006, 05:16 PM posted to microsoft.public.access.forms
Evert
external usenet poster
 
Posts: 47
Default Keep form open after Query command is excecuted?

I'm looking for a way to keep this Form open when the user closes the query.
Any Ideas or help would be appreciated.
I have the following form code:

Private Sub cmdCancel_Click()
DoCmd.Close acForm, "frmEmbQueryName"
End Sub

Private Sub cmdOK_Click()
If IsNull(cboName) Then
MsgBox "Please Select a Name or Cancel"
Exit Sub
End If
DoCmd.OpenQuery "qryEmbName", acViewNormal, acReadOnly
DoCmd.Close acForm, "frmEmbQueryName"
End Sub

Private Sub cmdViewPrint_Click()
If IsNull(cboName) Then
MsgBox "Please Select a Name or Cancel"
Exit Sub
End If
DoCmd.OpenQuery "qryEmbName", acViewNormal, acReadOnly
DoCmd.PrintOut
DoCmd.Close acForm, "frmEmbQueryName"
End Sub

  #2  
Old December 26th, 2006, 05:30 PM posted to microsoft.public.access.forms
Jeff C
external usenet poster
 
Posts: 392
Default Keep form open after Query command is excecuted?

Add this line after you close the form

DoCmd.Open acForm, "frmEmbQueryName"
--
Jeff C
Live Well .. Be Happy In All You Do


"Evert" wrote:

I'm looking for a way to keep this Form open when the user closes the query.
Any Ideas or help would be appreciated.
I have the following form code:

Private Sub cmdCancel_Click()
DoCmd.Close acForm, "frmEmbQueryName"
End Sub

Private Sub cmdOK_Click()
If IsNull(cboName) Then
MsgBox "Please Select a Name or Cancel"
Exit Sub
End If
DoCmd.OpenQuery "qryEmbName", acViewNormal, acReadOnly
DoCmd.Close acForm, "frmEmbQueryName"
End Sub

Private Sub cmdViewPrint_Click()
If IsNull(cboName) Then
MsgBox "Please Select a Name or Cancel"
Exit Sub
End If
DoCmd.OpenQuery "qryEmbName", acViewNormal, acReadOnly
DoCmd.PrintOut
DoCmd.Close acForm, "frmEmbQueryName"
End Sub

  #3  
Old December 26th, 2006, 05:42 PM posted to microsoft.public.access.forms
Evert
external usenet poster
 
Posts: 47
Default Keep form open after Query command is excecuted?

I added the line after the docmd.close and got a compile error " method or
data member not found" Pointing to Private sub cmdOK

any suggestions?

"Jeff C" wrote:

Add this line after you close the form

DoCmd.Open acForm, "frmEmbQueryName"
--
Jeff C
Live Well .. Be Happy In All You Do


"Evert" wrote:

I'm looking for a way to keep this Form open when the user closes the query.
Any Ideas or help would be appreciated.
I have the following form code:

Private Sub cmdCancel_Click()
DoCmd.Close acForm, "frmEmbQueryName"
End Sub

Private Sub cmdOK_Click()
If IsNull(cboName) Then
MsgBox "Please Select a Name or Cancel"
Exit Sub
End If
DoCmd.OpenQuery "qryEmbName", acViewNormal, acReadOnly
DoCmd.Close acForm, "frmEmbQueryName"
End Sub

Private Sub cmdViewPrint_Click()
If IsNull(cboName) Then
MsgBox "Please Select a Name or Cancel"
Exit Sub
End If
DoCmd.OpenQuery "qryEmbName", acViewNormal, acReadOnly
DoCmd.PrintOut
DoCmd.Close acForm, "frmEmbQueryName"
End Sub

  #4  
Old December 26th, 2006, 08:37 PM posted to microsoft.public.access.forms
John Vinson
external usenet poster
 
Posts: 4,033
Default Keep form open after Query command is excecuted?

On Tue, 26 Dec 2006 09:16:01 -0800, Evert
wrote:

I'm looking for a way to keep this Form open when the user closes the query.
Any Ideas or help would be appreciated.
I have the following form code:

Private Sub cmdCancel_Click()
DoCmd.Close acForm, "frmEmbQueryName"
End Sub

Private Sub cmdOK_Click()
If IsNull(cboName) Then
MsgBox "Please Select a Name or Cancel"
Exit Sub
End If
DoCmd.OpenQuery "qryEmbName", acViewNormal, acReadOnly
DoCmd.Close acForm, "frmEmbQueryName"
End Sub

Private Sub cmdViewPrint_Click()
If IsNull(cboName) Then
MsgBox "Please Select a Name or Cancel"
Exit Sub
End If
DoCmd.OpenQuery "qryEmbName", acViewNormal, acReadOnly
DoCmd.PrintOut
DoCmd.Close acForm, "frmEmbQueryName"
End Sub


Why open the Query at all!?

Query datasheets are generally best kept "under the hood". If you want
to display the data in qryEmbName, it's best to view it on a Form; if
you wish to print that information out, create a Report based on
qryEmbName and open that report (rather than using the Printout
method).

If you don't want to close frmEmbQueryName, then remove or comment out
the line DoCmd.Close acForm, "frmEmbQueryName". It's only closing the
form because you're asking that it be closed!
John W. Vinson[MVP]
  #5  
Old December 27th, 2006, 03:22 AM posted to microsoft.public.access.forms
Evert
external usenet poster
 
Posts: 47
Default Keep form open after Query command is excecuted?

Thank you, I tried it and it works better

"John Vinson" wrote:

On Tue, 26 Dec 2006 09:16:01 -0800, Evert
wrote:

I'm looking for a way to keep this Form open when the user closes the query.
Any Ideas or help would be appreciated.
I have the following form code:

Private Sub cmdCancel_Click()
DoCmd.Close acForm, "frmEmbQueryName"
End Sub

Private Sub cmdOK_Click()
If IsNull(cboName) Then
MsgBox "Please Select a Name or Cancel"
Exit Sub
End If
DoCmd.OpenQuery "qryEmbName", acViewNormal, acReadOnly
DoCmd.Close acForm, "frmEmbQueryName"
End Sub

Private Sub cmdViewPrint_Click()
If IsNull(cboName) Then
MsgBox "Please Select a Name or Cancel"
Exit Sub
End If
DoCmd.OpenQuery "qryEmbName", acViewNormal, acReadOnly
DoCmd.PrintOut
DoCmd.Close acForm, "frmEmbQueryName"
End Sub


Why open the Query at all!?

Query datasheets are generally best kept "under the hood". If you want
to display the data in qryEmbName, it's best to view it on a Form; if
you wish to print that information out, create a Report based on
qryEmbName and open that report (rather than using the Printout
method).

If you don't want to close frmEmbQueryName, then remove or comment out
the line DoCmd.Close acForm, "frmEmbQueryName". It's only closing the
form because you're asking that it be closed!
John W. Vinson[MVP]

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:31 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.