Parameter

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
 
D

Dirk Goldgar

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).
 
R

Rpettis31

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)
 
M

Marshall Barton

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 & """"
 

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