Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clear a Subform

Status
Not open for further replies.

jestrada101

Technical User
Mar 28, 2003
332
How can I add an event that clears a subform with data?

Thanks!
JE
 
Do you mean you want to set all the values of all the subform records to blank/null or do you want to delete all the records?

 
I would like to delete the records in the subform(it is in a datasheet format, so it has rows). How can I do that?
 
In the Click event procedure of a "delete" button in the main form:
Dim rs As DAO.Recordset
Set rs = Me![subform control name].Form.RecordsetClone
rs.MoveFirst
While Not rs.EOF
rs.Delete
rs.MoveNext
WEnd

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks!

Maybe you can give me a clue on donig what I'm trying to accomplish a better way.

I have a Main Form. In the main form I have two radio buttons (one selects RETAIL and the other WHOLESALE.

Based on this, the subform queries a table to either get a RETAIL or a WHOLESALE price for a particular product.

I need the "delete" because a user may have selected the wrong type of transaction (retail or wholesale). So right now, if they change the radio button to either one, the subform is completed deleted. there has to be a better way to do this... ANY HELP would be greatly appreciated!!

Thanks!!!



 
When people mention subforms you tend to think of a main form of say a customer then a subform of a set of products ordered by that customer ie related data simultaneously valid. You seem to be talking about displaying two forms in succession. The first one selects a price type and the second one displays it. It also seems you just have one record on the subform. I would just make sure the two command buttons redisplay the subform from scratch. You don't seem to want to add ,edit or delete the data.

 
if a user re-selects a price type,my prices in the subform do not get updated. How can I have the subform prices re-updated? The subform will have more than one product.

Thanks!
 
Your subform should be linked on the value of your option group radio buttons.

You DO have the radio buttons in an option group?

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Yes, they are in an option group, but I dont think I have them linked. When a user selects an option, a value is stored to a temporary variable, that is available in the subform. When user then selects a product, a query is done to get teh value/price.

Currently the subform is linked by a invoice number, can I add additional links? if so, how?

Thanks!
 
In that case - in the AfterUpdate event of the option group run that query again.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top