Enter parameter value, but it filters

L

laavista

I'm using Access 2003.

I have two forms, f_MilBase and f_Contact. Both have the field “BaseCodeâ€

On form f_MilBase, I have a command button. On Click, I wish to have form
f_Contact open with just the records for the BaseCode populated in f_MilBase

BaseCode is a text field, 5 char
Examples of BaseCodes in the db: 5234E or Beale

On click, the following code is executed:

If Not Me.NewRecord Then

DoCmd.OpenForm "f_contact", _
WhereCondition:="BaseCode=""" & Me.BaseCode & """"

End If

I get "enter parameter value", but when I enter nothing in the box and click
OK, it filters correctly.

Any help would be greatly appreciated!
 
D

Dorian

Normally this type of thing would be done with a subform.
Is there any particular reason why you cannot use a subform instead of a
separate form?
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
L

laavista

On the MilBase form, there's a lot of data already, so I can't add a subform
to the main MilBase form.

I tried having the command button on the main form (MilBase) to go to a
subform, but I could not get it to default to the base code that the user was
looking at on the MilBase form. The subform worked, but the user had to
choose which base they were viewing and that would be annoying.

Any suggestions?
 
J

John Spencer MVP

I would suspect that there is something in f_Contact's source that is
prompting you to enter parameter.

If you open f_Contact without the WHERE condition, do you get prompted? If
so, take a look at f_Contact and see if you can determine what is missing on
f_contact. Perhaps you changed a field name somewhere, perhaps you dropped a
field from the form's record source and were sorting by that field (check the
form's sorting and grouping dialog out).

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
L

laavista

John, you are worth your weight in gold. I had this problem with two forms.
I HAD previously changed a field and after you suggestion found that it
was causing the problem. I couldn't find where the problem was occurring (it
wasn't in the form's sorting and grouping dialog), but I just deleted those
forms and created new ones. Problem solved.

Again, THANK YOU.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top