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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enter Parameter Value 1

Status
Not open for further replies.

surfbum3000

Technical User
Aug 22, 2003
156
US
I have two forms: frmSearchDept and F_Search. When I open the frmSearchDept and click the X in the right hand corner, a message appears "Close the form?" with Yes/No. This works fine.
-----------------------------------------------------
Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Close the form?", vbYesNo) = vbNo Then
Cancel = True
Me![cboDept].SetFocus
End If
End Sub

The problem is on the F_Search form. When I click on a command button to open the frmSearchDept it opens fine. Then when I click on the X in the right hand corner, the following occurs: "Close the form?" with Yes/No. Click Yes. This is good so far but then I get a Enter Parameter Value titled Forms!frmSearchDept!cboDept. Click on Cancel and another message appears "The OpenReport action was canceled".

I want to eliminate the Enter Parameter Value window and just close the frmSearchDept.

The command button named cmdDeptSelect has the following under On Click:
--------------------------------------------
Private Sub DeptSelect_Click()
On Error GoTo Err_Loc_Click

Dim stDocName As String
stDocName = "rptSearchDept"
DoCmd.OpenReport stDocName, acPreview

Exit_Loc_Click:
Exit Sub

Err_Loc_Click:
MsgBox Err.Description
Resume Exit_Loc_Click

End Sub
 
Try...

Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Close the form?", vbYesNo) = vbNo Then
Cancel = True
Me.Setfocus
Me![cboDept].SetFocus
End If
End Sub
 
I tried making the change but it does not stop the "Enter parameter value" message box. To recap: The form F_Search contains a command button which opens a report named rptSearchDept, which has Record Source qrySearchDept. The qrySearchDept has the field Department with the criteria [forms]![frmSearchDept]![cboDept]. This works fine if you choose a Dept. to search. The problem occurs when the form is closed without entering anything.

1. Click cmdSearchDept button
2. Form frmSearchDept opens.
3. Click X in right hand corner.
4. Close the form? message box appears.
5. Click Yes
6. Enter Parameter Value appears.
7. Click Cancel
8. The OpenReport action was canceled.

Here is what I have in the OnClick procedure:
_______________________________________
Private Sub DeptSelect_Click()
On Error GoTo Err_Loc_Click

Dim stDocName As String

stDocName = "rptSearchDept"
DoCmd.OpenReport stDocName, acPreview

Exit_Loc_Click:
Exit Sub

Err_Loc_Click:
MsgBox Err.Description
Resume Exit_Loc_Click

End Sub
____________________________________________________
 
Something doesn't make sense... you must be clicking a button between steps 5 and 6.

The report or query under it is then trying to point to a control on a form that is not open. That is standard Access behavior. Queries take parameters... If it can't find it in the application it will ask for it.

I guess the question you have to ask yourself is, does the parameter belong?
 
Here is the solution I figured out. The rptSearchDept is based on the qrySearchDept which has the criteria [forms]![frmSearchDept]![cboDept]. Since the frmSearchDept is working just fine, I changed the DoCmd from trying to open the report to opening the frmSearchDept.

DoCmd.OpenReport stDocName, acPreview

to

Dim stDocName As String
stDocName = "frmSearchDept"
DoCmd.OpenForm stDocName
Cancel = True

Thanks lameid. Although you did not provide a direct solution your response got me to thinking about the process.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top