Clear contents of texbox in Subform from Main form (1 Viewer)

JPR

Registered User.
Local time
Today, 07:12
Joined
Jan 23, 2009
Messages
192
Hello,

I have a main form with two cmd buttons. The first cmdbutton opens a subform on which there is a textbox that I use as a query criteria. Results are displays in a listbox always on the Subform.

On the main form, I also have a second cmd button that should clear the contents of the textbox on teh Subform so that I can run a new query

This is the code I am using:


Forms!MainForm!Subform!textbox = Null

Thank you
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:12
Joined
May 7, 2009
Messages
19,230
you add Form object to your code, then requery the subform:
Code:
With Forms!MainForm!Subform.Form
    !textbox = Null
    .Requery
End With
 

bob fitz

AWF VIP
Local time
Today, 15:12
Joined
May 23, 2011
Messages
4,719
Hello,

I have a main form with two cmd buttons. The first cmdbutton opens a subform on which there is a textbox that I use as a query criteria. Results are displays in a listbox always on the Subform.

On the main form, I also have a second cmd button that should clear the contents of the textbox on teh Subform so that I can run a new query

This is the code I am using:


Forms!MainForm!Subform!textbox = Null

Thank you
You say that the button "opens" a subform but subforms are usually hidden or made visible. If you are actually opening another form then the code required would be something like:
Code:
Forms!NameOfForm.textboxName = Null
Forms!NameOfForm.Requery
 

Users who are viewing this thread

Top Bottom