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
If CmbQuery = "qry AM Current Month <0" Then
DoCmd.OpenQuery "qry AM Current Month <0", acViewDesign, acReadOnly
Else
If CmbQuery = "qry AM Current Month =0" Then
DoCmd.OpenQuery "qry AM Current Month =0", acViewDesign, acReadOnly
Else
If CmbQuery = "qry AM Current Month >0" Then
DoCmd.OpenQuery "qry AM Current Month >0", acViewDesign, acReadOnly
Else
If CmbQuery = "qry AM Current Year <0" Then
DoCmd.OpenQuery "qry AM Current Year <0", acViewDesign, acReadOnly
Else
If CmbQuery = "qry AM Current Year =0" Then
DoCmd.OpenQuery "qry AM Current Year =0", acViewDesign, acReadOnly
Else
If CmbQuery = "qry AM Current Year >0" Then
DoCmd.OpenQuery "qry AM Current Year >0", acViewDesign, acReadOnly
End If
End If
End If
End If
End If
End If
DoCmd.Close acForm, "Frm Choice of Query"
MsgBox "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.", vbExclamation, "Attention!"
End Sub
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 " ' " all your lines and paste in mine for the test. It should do the same thing but it has "error handling" too.
If you run the queries on their own (without using the form to "start" 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 "qry AM Current Month <0"
strQueryName = "qry AM Current Month <0"
Case "qry AM Current Month =0"
strQueryName = "qry AM Current Month =0"
Case "qry AM Current Month >0"
strQueryName = "qry AM Current Month >0"
Case "qry AM Current Year <0"
strQueryName = "qry AM Current Year <0"
Case "qry AM Current Year =0"
strQueryName = "qry AM Current Year =0"
Case "qry AM Current Year >0"
strQueryName = "qry AM Current Year >0"
End Select
DoCmd.OpenQuery strQueryName, acViewDesign, acReadOnly
DoCmd.Close acForm, "Frm Choice of Query"
MsgBox "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.", vbExclamation, "Attention!"
ExitCQAUD:
Exit Sub
ErrCQAUD:
MsgBox Err.Number & " " & Err.Description, vbInformation, "''Combo Query'' after update error."
Resume ExitCQAUD
End Sub
Gord
ghubbell@total.net
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));
Sylvain, your query looks pretty good but you can remove the "Like" in your criteria as you will only get the "DC" 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?]& "*" 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 "Close Button" set to False, and "Minimize/Maximize Buttons" set to "Minimize Only".
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 "Close Button" to True.
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.