Coding

M

Mavis

Hi All,

I have this below codes. In the last 4th line, (Me.Filter = "Status <>
'disposed'"), is there a way that i can allow user to select the "<>" and
'disposed" from a form. Which mean that i will have a form with a choice of
"<>" or "=", and the other status 'disposed", "In use", etc. the code will be
taken from the choices from the form.
Example: If the user select "=" and "In Use", then the code will become
Me.Filter = "Status = 'In Use'".


Private Sub Show_All_Records_Click()

'Button will display "Show All Records" when first load the form
'It will change to "Filter Records" once the button is click
If Show_All_Records.Caption = "Show All Records" Then
Show_All_Records.Caption = "Filter Records"

'All records will be display
Me.Filter = ""
Me.FilterOn = True

Else: Show_All_Records.Caption = "Show All Records"

'Record with Status does not equal to "disposed" will display
Me.Filter = "Status <> 'disposed'"
Me.FilterOn = True

End If

End Sub
 
M

Mike Painter

Mavis said:
Hi All,

I have this below codes. In the last 4th line, (Me.Filter = "Status <>
'disposed'"), is there a way that i can allow user to select the "<>"
and 'disposed" from a form. Which mean that i will have a form with a
choice of "<>" or "=", and the other status 'disposed", "In use",
etc. the code will be taken from the choices from the form.
Example: If the user select "=" and "In Use", then the code will
become Me.Filter = "Status = 'In Use'".
Me.filter = "Status" & EqualNotEqual & "'" & InuseOrNot & "'"

EqualNotEqual and InuseOrNot could be a combobox or listbox.

You can also use the onclick event to pick a value.

Select Case EqualNotEqual
case "="
EqualNotEqual = "<>"
case "<>"
EqualNotEqual = "="
end select


This works well with up to three choices, after that the combo or listbox
is probably better.
 
M

Mavis

Hi All,

I am very new to access. Not very sure how to do what you have adviced.
I have the below code but still unable to get what i want.

In parameterFilter, there is "=" and "<>" for the user to select
In ParameterStatus, There is all the status for example "inactive", "In Use"
and etc

Private Sub Show_All_Records_Click()

'Button will display "Show All Records" when first load the form
'It will change to "Filter Records" once the button is click
If Show_All_Records.Caption = "Show All Records" Then
Show_All_Records.Caption = "Filter Records"
Me.parameterFilter.Visible = True
Me.ParameterStatus.Visible = True
Me.FilterParameter.Visible = True

'All records will be display
Me.Filter = ""
Me.FilterOn = True

Else: Show_All_Records.Caption = "Show All Records"

Me.parameterFilter.Visible = False
Me.ParameterStatus.Visible = False
Me.FilterParameter.Visible = False

'Record with Status
Me.Filter = "Status" & Me.parameterFilter & "'Me.ParameterStatus'"
Me.FilterOn = True

End If

End Sub

Please kindly help me to solve my problem.
 

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