requery subform onclick

alvinks

New member
Local time
Today, 11:39
Joined
Oct 7, 2004
Messages
6
So not to waste peoples time I did spend 20 minutes searching the site and just could not find the right answer. Hopefully what I want is possible.

Using onclick from the parent form I am trying to requery a subform with a new sql statement that is based off of a textbox I have in the parent form. So if I put 'A' in my textbox then click the button it will bring up all records with A in the subform datasheet.

Thanks in advance for any help!
 
To requery a subform with a new sql statement, you can use code like this in the On Click event:
Code:
   Dim SQL As String
   
   SQL = "Select [Field1], [Field2], [Field3], [Fieldx]" & _
         " From [TableName]" & _
         " Where [Fieldx]='" & Me![TextBoxName] & "'"
 
   Me.[SubformName].Form.RecordSource = SQL
.
 
Thanks Jon. That is exactly what I needed!
 

Users who are viewing this thread

Back
Top Bottom