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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I reset only certain fields in a form & subform? 1

Status
Not open for further replies.

pbisaillon

Technical User
Aug 18, 2003
7
CA
Hi,

I currently have one form linked to a subform by a BoxID field that is being concatenated to get it's value. I have some fields on the main form that retrieves it's value from the Subform. I added a "clear form" button that clears all of the field values but that is no good!

I would like to only clear the BoxID field but keep all of the previous values in the other fields in the Main Form. I'm guessing that since my subform is linked to the BoxID field, all of it's fields will also reset? That is ok though.

make sense?

Thanks a lot,
Patrick
 
You might try using the DefaultValue property. For example, anytime a value changes in a field, in AfterUpdate event, set the DefaultValue property to the current value of the field.
 
Thanks.. Is there a code or certain expression that I put in the Default Value field?

Thanks a lot,
Patrick
 
For example, in the after update event of, say, txtBox1, you would put the following code.

txtBox1.DefaultValue = """" & txtBox1 & """"

Note that the DefaultValue must be a string.

I'm not sure this is what you're looking for. Therefore, just set one control to do this and see if it works like you want. If so, we can take it further.
 
That works like a charm!

Thanks a lot for your help,

Patrick
 
Glad it worked for you. This is how I would do it. I would shift-select all of the controls that I wanted to set the DefaultValue for and set the AfterUpdate event for all of them to something Like:

AfterUpdate... =SetDefaultValues()

Then I would create the following function:

Function SetDefaultValues()

Dim ctl as control

set ctl = Screen.ActiveControl

ctl.DefaultValue = """" & ctl & """"

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top