requery subform with new recordsource

  • Thread starter Thread starter krep
  • Start date Start date
K

krep

hello all - i think this is probably an easy one. i'm using access
2003. i have a form with a subform on it. i'd like to build a search
function - really just a textbox with a submit button. i just need to
requery the subform with the newly created sql string based on the
user's search criteria. how to requery a subform with a new
recordsource? thanks in advance.
 
Simplest way is to set the Filter

Sub txtBox_AfterUpdate()
Dim Sf As Access.Form
Set Sf = Me.SubFormControl.Form
If IsNull(Me.txtBox.Value) Then
Sf.FilterOn = False
Else
Sf.Filter = "WHERE FieldName Like '" & Me.txtBox.Value & "'"
Sf.FilterOn = True
End if
'Sf.Requery
Set Sf = Nothing ' Cleanup
End Sub

Pieter
 

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

Similar Threads


Back
Top