Parameter

  • Thread starter Thread starter Rpettis31
  • Start date Start date
R

Rpettis31

I am not sure what I am doing wrong but I am asking the user for an input to
filter on. Yet I get the parameter value pop up after the fact?
Private Sub cmdCustomer1_Click()
On Error GoTo Err_cmdCustomer1_Click

Dim Customer As String

Customer = InputBox("Please Select A Customer", "CUSTOMER SELECTION")

Me.subfrmInventoryList.Form.Filter = "[Customer]=" & Customer
Me.subfrmInventoryList.Form.FilterOn = True


Exit_cmdCustomer1_Click:
Exit Sub

Err_cmdCustomer1_Click:
MsgBox Err.Description
Resume Exit_cmdCustomer1_Click

End Sub
 
Rpettis31 said:
I am not sure what I am doing wrong but I am asking the user for an input
to
filter on. Yet I get the parameter value pop up after the fact?
Private Sub cmdCustomer1_Click()
On Error GoTo Err_cmdCustomer1_Click

Dim Customer As String

Customer = InputBox("Please Select A Customer", "CUSTOMER SELECTION")

Me.subfrmInventoryList.Form.Filter = "[Customer]=" & Customer
Me.subfrmInventoryList.Form.FilterOn = True


Exit_cmdCustomer1_Click:
Exit Sub

Err_cmdCustomer1_Click:
MsgBox Err.Description
Resume Exit_cmdCustomer1_Click

End Sub


Is Customer a text field? If so, you'll need to enclose user-supplied
customer name in quotes. Here's one way:

Me.subfrmInventoryList.Form.Filter = _
"[Customer]=" & Chr(34) & Customer & Chr(34)

That assumes that the customer name won't ever contain the double-quote
character ("), which is represented in the above code by Chr(34).
 
Its always these simple little things that drive me nuts....Thanks.

Dirk Goldgar said:
Rpettis31 said:
I am not sure what I am doing wrong but I am asking the user for an input
to
filter on. Yet I get the parameter value pop up after the fact?
Private Sub cmdCustomer1_Click()
On Error GoTo Err_cmdCustomer1_Click

Dim Customer As String

Customer = InputBox("Please Select A Customer", "CUSTOMER SELECTION")

Me.subfrmInventoryList.Form.Filter = "[Customer]=" & Customer
Me.subfrmInventoryList.Form.FilterOn = True


Exit_cmdCustomer1_Click:
Exit Sub

Err_cmdCustomer1_Click:
MsgBox Err.Description
Resume Exit_cmdCustomer1_Click

End Sub


Is Customer a text field? If so, you'll need to enclose user-supplied
customer name in quotes. Here's one way:

Me.subfrmInventoryList.Form.Filter = _
"[Customer]=" & Chr(34) & Customer & Chr(34)

That assumes that the customer name won't ever contain the double-quote
character ("), which is represented in the above code by Chr(34).

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Rpettis31 said:
I am not sure what I am doing wrong but I am asking the user for an input to
filter on. Yet I get the parameter value pop up after the fact?
Private Sub cmdCustomer1_Click()
On Error GoTo Err_cmdCustomer1_Click

Dim Customer As String

Customer = InputBox("Please Select A Customer", "CUSTOMER SELECTION")

Me.subfrmInventoryList.Form.Filter = "[Customer]=" & Customer


If the Customer field in its table is a Text field, then you
can use:

Me.subfrmInventoryList.Form.Filter = "[Customer]=""" &
Customer & """"
 
Back
Top