Full Version: Parameter Promt On Form Close
UtterAccess Forums > Microsoft® Access > Access Forms
Ron_Fowler
I'm using Access 97, and getting a Parameter Promt on DoCmd.Close
pparently,
DoCmd.Echo False
DoCmd.Close
DoCmd.Echo True
works for higher versions of Access, but it's not working with my Access 97 code.
Below is the code which closes one form and opens another.
Dim strUser As String
Dim stDocName As String
Dim stLinkCriteria As String
strUser = GetUserName()
If Left(strUser, 7) = "rfowler" Then
stDocName = "Scamp_1"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.close acform, Me.Name
End If
cocoflipper
your paramter point seems to be coming from the line:
oCmd.OpenForm stDocName, , , stLinkCriteria
you open the form with a WHERECONDITION of stLinkCriteria, but you don't set stLinkCriteria anywhere before that line of code, so Access is promting you for the value.
Either set stLinkCriteria to a string value before this line, or remove it from the OpenForm method.
Ron_Fowler
Thanks, but I removed it from the OpenForm Method DoCmd.OpenForm stDocName and still have the problem.
Any other thoughts??
cocoflipper
What's the prompt you are getting? Also, what is the line you have for the OpenForm method?
Ron_Fowler
I'm getting "Enter Parameter Value" Forms!MM1!ComboCal
penForm Method Code
Private Sub Form_Open(Cancel As Integer)
EnableControls Me, acDetail, True
With Me ' To establish scroll bars on low resolution screens.
If .InsideWidth < 11800 And .InsideHeight < 7305 Then
.ScrollBars = 3
ElseIf .InsideWidth < 11800 Then
.ScrollBars = 1
ElseIf .InsideHeight <= 7200 Then
.ScrollBars = 2
Else: .ScrollBars = 0
End If
End With
UserNameLabel.Caption = GetUserName()
Dim strUser As String
Dim stDocName As String
Dim stLinkCriteria As String
strUser = GetUserName()
If Left(strUser, 7) = "rfowler" Then
stDocName = "Scamp_1"
DoCmd.OpenForm stDocName
DoCmd.Close acForm, Me.Name
Else
ComboCal.Value = "5.56"
ComboArea.Value = "Primer"
'If ComboCal.Value = "Links" Then
'ComboArea.Value = "M27"
'Else
'ComboArea.Value = "Primer"
'End If
Me!MainListBox1.Enabled = True
Me!MainListBox1.Requery
EnableControls Me, acDetail, True
Me!ComboArea.Enabled = True
Me!ComboArea.Requery
EnableControls Me, acDetail, True
Me!ComboPart.Enabled = True
Me!ComboPart.Requery
EnableControls Me, acDetail, True
ComboPart.Value = " "
Me!ComboDimen.Enabled = True
Me!ComboDimen.Requery
EnableControls Me, acDetail, True
ComboDimen.Value = " "
End If
End Sub
cocoflipper
Have you followed this code using the debugger to see where in the code it is requesting the parameter?
lso - one other thing to check...Does this happen if you open the form "Scamp_1" on it's own?
Ron_Fowler
Scamp_1 opens fine if you open it by itself. I've also got the same code in a button for the user's to press, and it works fine there. It's when I use the First Forms - On Open Event that I have the problem.
I used the debugger and didn't see the problem, however, I'm not that skilled with the debugger to know if I did it right. I used F8 to step through the code.
Thanks again. If you have anymore thoughts, let me know....
cocoflipper
What is ComboCal - that's the parameter it's asking for? It's in your code twice, once edited out as a comment. Is it in the MM1 form as a control? If not, one thought is that this code --- ComboCal.Value = "5.56" --- might need to commented out...
Ron_Fowler
On the main form, MM1, ComboCal.Value is the startup setting for the ComboCal Combobox.
On the MM1 Form, there are 4 Combobox's. Two of those Combobox's have startup settings, and those are the one's prompting for a Parameter Value. Those Combobox's that don't have startup values don't prompt for a value.
However, with the If else End If statement written as it is, I can't see that it would ever get to the code. I tried setting ComboCal.Value in the If statement when the condition is true, but it didn't seem to make a difference.
Thanks for your continued review..... Ron
cocoflipper
Whenever I've run into an area where I was asked for a parameter, it usually pointed to something on the form or a controlsource on a control on the form which didn't match the record source of the form.
When you say startup settings, do you mean record source of the combobox?
And what is enableControls - is that a function you made? Perhaps you might need to send me the db so I can open the form up on my own and provide you with some feedback...
Ron_Fowler
I'll attach a copy of the database. The form is "MM1" However, you'll need to set the condition in the IF statement to some true statement. Right now, the condition is true, "If Left(strUser, 7) = "rfowler" Then" and that's when the error occurs.
The enableControls are functions that I took from another application. I thought it was Northwind that comes with Access.
When I say startup, that means I just wanted the ComboBox to be filled with the common information for most users.
Thanks again..... Ron
cocoflipper
Ron
All I'm getting on your attachment is a jpg file. Did you take your .mdb, zip it up, then attach it?
By the way, I checked through my Northwind.mdb, at least the 2002 version, and there is no EnableControls. You'll probably have to make sure that this function is included with the database you attach.
Ron_Fowler
I just named the file .jpg because it told me it would not accept .mdb.
So, if you change that file extension to .mdb, it should open as an .mdb file.
Sorry for the confusion.
Ron_Fowler
By the way, since you have the database, if you set the If condition to false and view the MM1 Form, you can press the "SCAMP L2S" button on the right side and it will go to the 2nd form, SCAMP_1 without the "Enter Parameter Value" prompt. It just seems to be related to the On_Open_Event.
Thanks again for all your help.
cocoflipper
The Utteraccess site won'tgive me the chance to rename it. I suggest doing what everyone else does at this site, put it in a zip file.

**** Edited - OK I got it....I'll take a look at it...
Edited by: cocoflipper on Mon Jan 16 16:29:36 EST 2006.
Ron_Fowler
Thanks...
We seem to be dated in technology. That's why we're still on Access 97.
I'll have to see about coming up with the Zip utility.
Thanks
cocoflipper
Upon initial look, the name of the listbox does not match the name of the listbox used in a query in the MM1 form (the form listbox is MainListBox1 and the query looks to MainListBox)

Try either one of these...

- Go to your MM1 form and change the name of the listbox to "MainListBox"

OR

- Go to the query SelectPart and change the value of the [MainListBox].[Caliber])=[Forms]![MM1]![ComboCal] to [MainListBox1].[Caliber])=[Forms]![MM1]![ComboCal]

...same for ComboArea

Let me know how that works...
Edited by: cocoflipper on Mon Jan 16 16:50:24 EST 2006.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.