Filter a subform

mattbrem

Registered User.
Local time
Today, 11:27
Joined
Oct 13, 2008
Messages
11
Hi,

I have an unbound form with a subform that is linked to a table called Master Table. The subform is just a datasheet view to look at records. I have controls on the main form that should allow the user to enter the last name of someone and when they click search the form filters the subform based on the name entered. Whenever I click search a dialog box pops up asking me for parameters.

Here is the code for search.

Private Sub cmdSearch_Click()

Dim stfilter As String
stfilter = txtLastName.Value

Me.subLocater.Form.filter = "[Master Table].[Last Name] = " & stfilter
Me.subLocater.Form.FilterOn = True


End Sub

I have also tried setting the record source of the subform based on the text box like this

Private Sub cmdSearch_Click()

Dim stfilter As String
stfilter = txtLastName.Value
Me.subLocater.Form.recordSource = "SELECT * FROM [Master Table] WHERE [Last Name] = " & stfilter



End Sub

And a popup box comes up again asking for the parameters of whatever was entered into the text box, so if I put in Smith in the text box and click search it pops up asking for the parameters of smith as if smith were a field.


Any ideas?
 
Howzit

Does this make any difference?

Code:
Me.subLocater.Form.filter = "[Master Table].[Last Name] = '" & stfilter & "'"
 

Users who are viewing this thread

Back
Top Bottom