473,419 Members | 1,635 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

How to create a button to clear a subform from a main form

Fspinelli
I have a query by form set up.

I coded and can get the fields on the form to clear by the click of a button, but how do I make the subform clear, too?

The main form has a "Clear" button and in the "event procedure" I placed the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdClear_Click()
  2.  
  3.     Me.txtFname = Null
  4.     Me.txtLname = Null
  5.     Me.cboCountry = Null
  6.     Me.cboDistribution = Null
  7.     Me.cboPlatform = Null
  8.     Me.cboState = Null
  9.     Me.cboStatus = Null
  10.     Me.cboType = Null
  11.  
  12. End Sub
When the button is clicked, all of the criteria fields clear but I am not sure how to make it so the subform with the results below it clear, too.

I would greatly appreciate assistance.

Thank you.
Aug 25 '10 #1
6 13890
Jerry Maiapu
259 100+
The format to access a particula field in a subform from main/parent form is
Expand|Select|Wrap|Line Numbers
  1. Forms!MainFormName!Subformname!Subform_Textbox_name
so try something like
Expand|Select|Wrap|Line Numbers
  1. Forms!MainForm Name!Subform Name!Subform_Textbox_name1=Null
  2. Forms!MainFormName!Subformname!Subform_Textbox_name2=Null
or else try this format.
Expand|Select|Wrap|Line Numbers
  1. me!Subformname!Subform_Textbox_name
Aug 25 '10 #2
munkee
374 256MB
i just use
Expand|Select|Wrap|Line Numbers
  1. Me.subfrmcontrolname.form.controlonsubfrm = ""

Where subfrmcontrolname is the name of your subform on your main form. Not the name of the actual subform as per your convention on your database window.

The control name of the subform can differ to the actual form loaded within it.
Aug 26 '10 #3
Thank you very much for your help.

However, I found I could clear the form by simply placing
Expand|Select|Wrap|Line Numbers
  1. Me.CONTROLNAME = Null
  2. (etc, if more)
  3. Me.frmNAMEOFSubform.Requery
So once you hit "clear", it requeries based on nothing and produces nothing, clearing the subform.

I don't know if this is the correct way, but it produced nice results for me.

I greatly appreciate your guidance.
Aug 27 '10 #4
NeoPa
32,556 Expert Mod 16PB
If that's what you're trying to do, then that's the correct way. Unfortunately your question gave no clue that you desired that effect. In fact it gave an example that implied otherwise. We can only answer your question if you ask it properly.
Aug 27 '10 #5
Can't read a woman's mind? Just kidding...

I see, thank you NeoPa, I will consider that in the future.

I was just not sure how to ask it I suppose. But utilizing other's advise helped me learn a few more things and I really appreciate that.

Have a very pleasant weekend.
Aug 27 '10 #6
NeoPa
32,556 Expert Mod 16PB
FSpinelli:
Can't read a woman's mind?
I expect that's it :D

Of course I do realise expressing one's question clearly can be difficult (If I didn't realise that by now I really would be stupid), but I like to bring attention to the importance of it when I get the opportunity.

You'd be surprised how many members don't appreciate that in a forum environment, without all the extra clues you get talking face to face or seeing the project (DB) in front of you, the expression of the question is so much more important.

I know I come off as grumpy sometimes, which is something I can live with if I must, but I'm trying to guide those members to a better way of using the facilities (here and elsewhere of course).

Anyway, have a very pleasant weekend yourself and I'm very glad you managed to resolve your issue :)
Aug 27 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mike Cocker | last post by:
Hello, I'm quite weak at PHP, so I was hoping to get some help understanding the below code. First off, I'm trying to create a "query form" that will allow me to display the results on my...
7
by: Cues Plus | last post by:
Hello, I have a simple form text area for people to add comments in. The problem is that using the standard <TEXT AREA NAME="comments" ROWS=4 COLS=35></TEXT AREA> Allows people to put in...
3
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
1
by: google | last post by:
It would seem that when I assign an HTML entity to a form text input using "inline" javascript that it will display properly. But when trying to set it via a function call, the entity text shows...
1
by: Dman | last post by:
MS Access 2002 - query form control returns funny symbols like I am running an append query on a form. Access is having trouble with the calculated fields and comboboxes. Example – referring...
1
by: abracad_1999 | last post by:
is there a way to allow user to hit enter in a form text box and run a javascript function rather than submitting the form?
6
by: alxcy | last post by:
Hello , Im new here and generally in the Database world, just started learning access while doing a little project. I created a normal Database in MS Access 2003 with one table and one form to...
10
by: FNA access | last post by:
Hello to the world of the wise, I am a CSOM student at TRU. I am trying to design a database to improve my understanding. The problem I am having is with setting up a query. I have a Query...
3
by: Richard | last post by:
Hi all. I have a PHP form for entering data on-line into a mySQL table.. Because of the intended search facility, I require one field in the form to be completed with exact and precise item names...
5
by: patriciashoe | last post by:
I have a textbox in a form that is derived by the use of a function that I created. This is working just fine. I now have the need to take this value and apply some additional logic to the value to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.