Filtering a form using a inputbox

  • Thread starter Thread starter Brent
  • Start date Start date
B

Brent

I have the following code in a form I'm using. When I click on the button
to run this it brings up the input box twice. Once as I would expect it and
the next time it shows the information typed into the input box as the
prompt data. Any ideas on what I need to correct?


Dim myvalue As String
myvalue = InputBox("Enter Last Name", "Search")
Me.Filter = "[lastname] =" & myvalue & ""
Me.FilterOn = True
 
Brent said:
I have the following code in a form I'm using. When I click on the
button to run this it brings up the input box twice. Once as I would
expect it and the next time it shows the information typed into the
input box as the prompt data. Any ideas on what I need to correct?


Dim myvalue As String
myvalue = InputBox("Enter Last Name", "Search")
Me.Filter = "[lastname] =" & myvalue & ""
Me.FilterOn = True

I think you have your quotes wrong. Try this...

Dim myvalue As String
myvalue = InputBox("Enter Last Name", "Search")
Me.Filter = "[lastname] ='" & myvalue & "'"
Me.FilterOn = True

(notice I added some single quotes)
 
Compared to others here, I'm a novice at this, but I think this will work:

Me.Filter = "[lastname] ='" & InputBox("Enter Last Name", "Search") & "'"
Me.FilterOn = True

What it seems you forgot were the little single quotes after the equal sign
and between the two double quotes at the end. I combined things into only
two lines, but that's just my preference.

Hope this helps
brba
 
Works great. Thank you so much.

Brent
Rick Brandt said:
Brent said:
I have the following code in a form I'm using. When I click on the
button to run this it brings up the input box twice. Once as I would
expect it and the next time it shows the information typed into the
input box as the prompt data. Any ideas on what I need to correct?


Dim myvalue As String
myvalue = InputBox("Enter Last Name", "Search")
Me.Filter = "[lastname] =" & myvalue & ""
Me.FilterOn = True

I think you have your quotes wrong. Try this...

Dim myvalue As String
myvalue = InputBox("Enter Last Name", "Search")
Me.Filter = "[lastname] ='" & myvalue & "'"
Me.FilterOn = True

(notice I added some single quotes)
 
Back
Top