Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cant get an X to close... 2

Status
Not open for further replies.

sylvain

Technical User
Mar 20, 2001
39
CA
When the results of my query pops up, i cant get the X to close it, i only have the option to minimise the window.
How can get that X back

Tanks
Sylvain Richard
 
Hi Sylvain,
Can you display your query here for all to see? What type of query is it? Go to the SQL view & copy/paste here and we'll solve it! Gord
ghubbell@total.net
 
here is the query

Private Sub CmbQuery_AfterUpdate()

If CmbQuery = &quot;qry AM Current Month <0&quot; Then
DoCmd.OpenQuery &quot;qry AM Current Month <0&quot;, acViewDesign, acReadOnly
Else
If CmbQuery = &quot;qry AM Current Month =0&quot; Then
DoCmd.OpenQuery &quot;qry AM Current Month =0&quot;, acViewDesign, acReadOnly
Else
If CmbQuery = &quot;qry AM Current Month >0&quot; Then
DoCmd.OpenQuery &quot;qry AM Current Month >0&quot;, acViewDesign, acReadOnly
Else
If CmbQuery = &quot;qry AM Current Year <0&quot; Then
DoCmd.OpenQuery &quot;qry AM Current Year <0&quot;, acViewDesign, acReadOnly
Else
If CmbQuery = &quot;qry AM Current Year =0&quot; Then
DoCmd.OpenQuery &quot;qry AM Current Year =0&quot;, acViewDesign, acReadOnly
Else
If CmbQuery = &quot;qry AM Current Year >0&quot; Then
DoCmd.OpenQuery &quot;qry AM Current Year >0&quot;, acViewDesign, acReadOnly
End If
End If
End If
End If
End If
End If
DoCmd.Close acForm, &quot;Frm Choice of Query&quot;
MsgBox &quot;Please do not change anything in this query. You can do another one if you want. To execute this query, you click on the datasheet icon that will show up at the upper left corner and to get back in the design mode, you click on the bleu triangle icon in the same corner. To exit the query, you click on the X at the upper right corner.&quot;, vbExclamation, &quot;Attention!&quot;
End Sub


Thanks for your help
 
Ok Sylvain, This is cool but is it the query that hangs up or is it the form that you're trying to close?
I've cleaned up some code for you to try. just comment &quot; ' &quot; all your lines and paste in mine for the test. It should do the same thing but it has &quot;error handling&quot; too.
If you run the queries on their own (without using the form to &quot;start&quot; them do they hang? If this is the case, let's see the queries...

Private Sub CmbQuery_AfterUpdate()
On Error GoTo ErrCQAUD
Dim strQueryName As String
Select Case Me.CmbQuery
Case &quot;qry AM Current Month <0&quot;
strQueryName = &quot;qry AM Current Month <0&quot;
Case &quot;qry AM Current Month =0&quot;
strQueryName = &quot;qry AM Current Month =0&quot;
Case &quot;qry AM Current Month >0&quot;
strQueryName = &quot;qry AM Current Month >0&quot;
Case &quot;qry AM Current Year <0&quot;
strQueryName = &quot;qry AM Current Year <0&quot;
Case &quot;qry AM Current Year =0&quot;
strQueryName = &quot;qry AM Current Year =0&quot;
Case &quot;qry AM Current Year >0&quot;
strQueryName = &quot;qry AM Current Year >0&quot;
End Select
DoCmd.OpenQuery strQueryName, acViewDesign, acReadOnly
DoCmd.Close acForm, &quot;Frm Choice of Query&quot;
MsgBox &quot;Please do not change anything in this query. You can do another one if you want. To execute this query, you click on the datasheet icon that will show up at the upper left corner and to get back in the design mode, you click on the bleu triangle icon in the same corner. To exit the query, you click on the X at the upper right corner.&quot;, vbExclamation, &quot;Attention!&quot;

ExitCQAUD:
Exit Sub

ErrCQAUD:
MsgBox Err.Number & &quot; &quot; & Err.Description, vbInformation, &quot;''Combo Query'' after update error.&quot;
Resume ExitCQAUD
End Sub
Gord
ghubbell@total.net
 
Hi again

Thanks for your help, its in the form that i cant get the X
(Sorry i did not say before..)

Here is the code for the query

SELECT AM.Banner_No, AM.Banner_Desc, AM.Product_Line, AM.Product_Desc, AM.Product_Family, AM.Family_Desc, AM.DC_No, AM.DC_Name, AM.Store_No, AM.Store_Name, AM.Customer_No, AM.Customer_Name, AM.Current_Month, AM.Current_YTD, AM.Previous_YTD
FROM AM
WHERE (((AM.DC_No) Like [Which DC would you like to see?]) AND ((AM.Current_Month)<0));

I ll try the code you sent me now......
 
Sylvain, your query looks pretty good but you can remove the &quot;Like&quot; in your criteria as you will only get the &quot;DC&quot; that is entered by the user. If you were searching for say:
30,31,32 and your user typed in 3 when prompted, you could use:
Like [Which DC would you like to see?]& &quot;*&quot; to return 30, 31,32. Gord
ghubbell@total.net
 
I agree with Garridon here (about the reason for the X not being there, that is). It sounds as if the form may have &quot;Close Button&quot; set to False, and &quot;Minimize/Maximize Buttons&quot; set to &quot;Minimize Only&quot;.

Quick question.. did you design this form, or did another programmer? The reason I ask is that this isn't something Access does by default, so odds are, whoever designed the form this way, did it on purpose and there's probably a reason for it. Is there a Close button on the form itself? It may have code behind it that the programmer needs to run on close (but for some reason couldn't just put in the OnClose event handler). In any event, you might want to check these things out before setting &quot;Close Button&quot; to True.

Hope that helps.. :cool:
 
Sylvian, Est ce que c'est possible? (Is it possible?) that you never have an enabled X on your form as our friends have suggested? !!! Gord
ghubbell@total.net
 
Well

Thanks to all of you for your help, i am a first time user of this site and you bet that its bookmarked now...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top