Resetting forms

J_Orrell

Registered User.
Local time
Today, 23:12
Joined
May 17, 2004
Messages
55
Hi there gurus...

I have made a form with various text-boxes, radio-buttons and other controls on it. The form is not bound to a table or query: I'm just using the form as a data-gathering device for my VBA code. After the user has entered the data I want to use a button to reset the boxes and controls to the way they were when the form was openened, ie as though the user closed the form down and re-opened it again. I know I can do this by resetting the .value of each control back to its default, but there's about 30 controls to reset! Is there not something like "forms!main.reset" that just resets all the controls a form back to their default values, clears out text boxes, etc etc as though the user has closed & reopened the form?

Ta
John
 
one solution (not pretty) would be when you click on your button to close the form and then open it again
 
John,

Try this, you will have to add to the "blue part"


Code:
' Clear all unbound Text Boxes and Combo boxes
Dim ctl As Control
For Each ctl In Me.Controls
    If ctl.ControlType = [COLOR="Blue"]acComboBox Or ctl.ControlType = acTextBox[/COLOR] Then
        ctl.Value = ""
    End If
Next ctl
Set ctl = Nothing
 
ansentry said:
John,

Try this, you will have to add to the "blue part"


Code:
' Clear all unbound Text Boxes and Combo boxes
Dim ctl As Control
For Each ctl In Me.Controls
    If ctl.ControlType = [COLOR="Blue"]acComboBox Or ctl.ControlType = acTextBox[/COLOR] Then
        ctl.Value = ""
    End If
Next ctl
Set ctl = Nothing

Thanks, dude, that's exactly what I was looking for! :D
 
ansentry said:
acCheckBox

That worked but it only cleared the 1st check box and not all the boxes on the form.

Each row in the form has a print check box at the end so you cn select the lines to print...is there a way to make it clear all the checkboxes?

Thanks!
 
For checkboxes you have to set them equal to FALSE, not "".
 
boblarson said:
For checkboxes you have to set them equal to FALSE, not "".

Thanks but it is still only clearring the 1st box. My form has 38 rows and currently 4 check boxes (print box) selected. Is it because it is a field in the table?

UGH!
 
Have a look at the attached sample.

Examples for both single and continuous forms, one uses code and the other a query.
 
Last edited:
Try This Edit

Code:
Dim ctl As Control
For Each ctl In Me.Controls
    Select Case ctl.ControlType
           Case acComboBox, acTextBox
                  ctl = ""
          Case acCheckBox
           ctl = False
    End Select
Next ctl
Set ctl = Nothing
 
Database Attached...

Sorry for the delay....I have been off for a month with surgery and trying to work on this as well so I've been somewhat in and out.

I have tried shrinking th database to 1 record in each table but it is still 910kb and it won't post it so let me try to better explain. I can email it to anyone who wants to look at it.

When a car comes in an inspection is done and an estimate submitted..usually 10-15 lines or so. Each line contains:

* the description (drop down box as most descirptions are repeated),
* job code (drop down box)
* WhymadeCode (drop Down Box)
* Condition Code (drop down box)
* materials (if any) drop down box) (for just this line/item)
* labor (for just this line/item)
* total
* print (checkbox)
they contain more than this but you get the idea...

All lines need to be printed and submitted for estimate approval. Once the approval is received we need to be able to select those lines and enter it on each line, this is done by selecting print on the appropriate line and opening the approvals form so that only those lines appear.

Once approved it moves to another team for yet another inspection....these lines are then added to the job detail and need to be printed individually and submitted for a supplemental approval. Once approved the supplemental approval needs to be entered into each line.

While that work is being performed usually more items are found and there can be up to 4 more submissions...each with their own supplemental approval number and each needing to be printed individually.

When complete.....all lines need to be checked off for the final invoice and output into their 500byte format....hence the need for the separation of the estimate approval number and supplemental approval number.

I need to be able to check all/uncheck all boxes. None of the above is working. It only clears the top line.

I also need to enter the estimate approval or supplemental approval number in the appropriate form and have it fill in the blanks for the lines checked and save it. (go to work order, job detail, and enter approvals) This is working as far as filling in but not saving.

Your help is GREATLY appreciated!!!

P.S. I am attaching a copy of the MANDATORY 500bit information to give you an idea of why the approvals have to be separated. I have a query that appends a table which is then exported to a fixed width text file and submitted to the customer.
 

Attachments

Users who are viewing this thread

Back
Top Bottom