Option group & paramater error

O

Opal

I have a form that I wish to use an option group to filter a field on
the sub-form.

I have input the following code:

Private Sub fraStatus_AfterUpdate()
If Me.fraStatus.Value = 2 Then
Me.Filter = "Status = Closed"
Me.FilterOn = True
ElseIf Me.fraStatus.Value = 1 Then
Me.Filter = "Status = Open"
Me.FilterOn = True
Else
Me.FilterOn = False
End If
End Sub

I have also placed the following code in the subform:

Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
If ApplyType = acShowAllRecords Then
Me.fraStatus.Value = 3 'Show all records
Me.fraStatus.Enabled = True
Else
Me.fraStatus.Value = Null 'No option button selected
Me.fraStatus.Enabled = False
End If
End Sub

Every time I make a change to "open" or "closed" in the Option
group I get a pop-up stating:

"Enter Parameter Value

Status"

I cannot figure out what I am missing to get this to work...
can anyone help? I am running Access 2003. Thank you.
 
D

Douglas J. Steele

Status is obviously a text field (since you're comparing it to text values),
so that comparison values need to be in quotes.

Private Sub fraStatus_AfterUpdate()
If Me.fraStatus.Value = 2 Then
Me.Filter = "Status = 'Closed'"
Me.FilterOn = True
ElseIf Me.fraStatus.Value = 1 Then
Me.Filter = "Status = 'Open'"
Me.FilterOn = True
Else
Me.FilterOn = False
End If
End Sub
 
O

Opal

Status is obviously a text field (since you're comparing it to text values),
so that comparison values need to be in quotes.

 Private Sub fraStatus_AfterUpdate()
 If Me.fraStatus.Value = 2 Then
    Me.Filter = "Status = 'Closed'"
    Me.FilterOn = True
 ElseIf Me.fraStatus.Value = 1 Then
    Me.Filter = "Status = 'Open'"
    Me.FilterOn = True
 Else
    Me.FilterOn = False
 End If
 End Sub

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no private e-mails, please)












- Show quoted text -

Thanks Doug, but even if I change it to:


Private Sub fraStatus_AfterUpdate()
If Me.fraStatus.Value = 2 Then
Me.Filter = "Status = 'Closed'"
Me.FilterOn = True
ElseIf Me.fraStatus.Value = 1 Then
Me.Filter = "Status = 'Open'"
Me.FilterOn = True
Else
Me.FilterOn = False
End If
End Sub

I get the same parameter "pop-up"

I'm sure it has something to do with using a subform that has the
Status text box
and the Option group is on the main form...but I can't quite figure it
out......

I have done this before when all were on one form, but I cant get it
to work here...
 
D

Douglas J. Steele

If that code is in the subform, and fraStatus is on the parent form, you
likely need

If Me.Parent.fraStatus.Value = 2 Then

However, getting a parameter pop-up implies something wrong with the filter,
not something wrong with how you're setting the filter.

Exactly what is the pop-up looking for? Is it looking for Status? Does
Status exist in the recordset of the subform?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Status is obviously a text field (since you're comparing it to text
values),
so that comparison values need to be in quotes.

Private Sub fraStatus_AfterUpdate()
If Me.fraStatus.Value = 2 Then
Me.Filter = "Status = 'Closed'"
Me.FilterOn = True
ElseIf Me.fraStatus.Value = 1 Then
Me.Filter = "Status = 'Open'"
Me.FilterOn = True
Else
Me.FilterOn = False
End If
End Sub

Thanks Doug, but even if I change it to:


Private Sub fraStatus_AfterUpdate()
If Me.fraStatus.Value = 2 Then
Me.Filter = "Status = 'Closed'"
Me.FilterOn = True
ElseIf Me.fraStatus.Value = 1 Then
Me.Filter = "Status = 'Open'"
Me.FilterOn = True
Else
Me.FilterOn = False
End If
End Sub

I get the same parameter "pop-up"

I'm sure it has something to do with using a subform that has the
Status text box
and the Option group is on the main form...but I can't quite figure it
out......

I have done this before when all were on one form, but I cant get it
to work here...
 
O

Opal

If that code is in the subform, and fraStatus is on the parent form, you
likely need

If Me.Parent.fraStatus.Value = 2 Then

However, getting a parameter pop-up implies something wrong with the filter,
not something wrong with how you're setting the filter.

Exactly what is the pop-up looking for? Is it looking for Status? Does
Status exist in the recordset of the subform?

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no private e-mails, please)





Thanks Doug, but even if I change it to:

Private Sub fraStatus_AfterUpdate()
If Me.fraStatus.Value = 2 Then
    Me.Filter = "Status = 'Closed'"
    Me.FilterOn = True
ElseIf Me.fraStatus.Value = 1 Then
    Me.Filter = "Status = 'Open'"
    Me.FilterOn = True
Else
    Me.FilterOn = False
End If
End Sub

I get the same parameter "pop-up"

I'm sure it has something to do with using a subform that has the
Status text box
and the Option group is on the main form...but I can't quite figure it
out......

I have done this before when all were on one form, but I cant get it
to work here...- Hide quoted text -

- Show quoted text -

The pop-up is looking for Status. There is a combo box in the subform
labelled cboStatus that has a row source from the Countermeasure table
bound to the subform of: SELECT Status.StatusID, Status.Status FROM
Status;

Since the Option group is in the main part of the form, I put a text
box there and
linked it to the cboStatus box on the subform
(=subformCountermeasure.Form!cboStatus)
in the hopes that the Option group would work, but I still get the
parameter pop-up.
 
D

Douglas J. Steele

You didn't answer the question of whether a field named Status actually
exists in the recordsource of the form.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


If that code is in the subform, and fraStatus is on the parent form, you
likely need

If Me.Parent.fraStatus.Value = 2 Then

However, getting a parameter pop-up implies something wrong with the
filter,
not something wrong with how you're setting the filter.

Exactly what is the pop-up looking for? Is it looking for Status? Does
Status exist in the recordset of the subform?

The pop-up is looking for Status. There is a combo box in the subform
labelled cboStatus that has a row source from the Countermeasure table
bound to the subform of: SELECT Status.StatusID, Status.Status FROM
Status;

Since the Option group is in the main part of the form, I put a text
box there and
linked it to the cboStatus box on the subform
(=subformCountermeasure.Form!cboStatus)
in the hopes that the Option group would work, but I still get the
parameter pop-up.
 
O

Opal

You didn't answer the question of whether a field named Status actually
exists in the recordsource of the form.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)







The pop-up is looking for Status.  There is a combo box in the subform
labelled cboStatus that has a row source from the Countermeasure table
bound to the subform of:  SELECT Status.StatusID, Status.Status FROM
Status;

Since the Option group is in the main part of the form, I put a text
box there and
linked it to the cboStatus box on the subform
(=subformCountermeasure.Form!cboStatus)
in the hopes that the Option group would work, but I still get the
parameter pop-up.

There is no field named status in the form. There is a field named
status in the Status table.
There is a relationship between the Countermeasure table and the
Status table and the
Countermeasure table is bound to the Countermeasure subform.
 
D

Douglas J. Steele

If you're trying to use Status in a filter, then Status must exist in the
form's RecordSource. It's not essential that it be bound to a control on the
form, but it must be in the table or query to which the form is bound.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


You didn't answer the question of whether a field named Status actually
exists in the recordsource of the form.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)







The pop-up is looking for Status. There is a combo box in the subform
labelled cboStatus that has a row source from the Countermeasure table
bound to the subform of: SELECT Status.StatusID, Status.Status FROM
Status;

Since the Option group is in the main part of the form, I put a text
box there and
linked it to the cboStatus box on the subform
(=subformCountermeasure.Form!cboStatus)
in the hopes that the Option group would work, but I still get the
parameter pop-up.

There is no field named status in the form. There is a field named
status in the Status table.
There is a relationship between the Countermeasure table and the
Status table and the
Countermeasure table is bound to the Countermeasure subform.
 
O

Opal

If you're trying to use Status in a filter, then Status must exist in the
form's RecordSource. It's not essential that it be bound to a control on the
form, but it must be in the table or query to which the form is bound.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)






There is no field named status in the form.  There is a field named
status in the Status table.
There is a relationship between the Countermeasure table and the
Status table and the
Countermeasure table is bound to the Countermeasure subform.- Hide quoted text -

- Show quoted text -

In a similar database I have worked on, I had the filter as "Media"
but Media
did not exist in the form. Media ID existed in the Table for which
the form was
bound. Media existed in a separate table where a relationship existed
between
it and the Film table for which the form was bound.

In this case I have a form bound to a table called Concern. There is
a relationship
between Concern and a table called Countermeasure. The Countermeasure
table
is bound to the Countermeasure subform which exists in the
frmConcern. In the
Countermeasure table there is a field called StatusID. There is a
relationship
between this field and the Status table where the field "Status"
exists.

Clear as mud?
 

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