|
-
Dec 3rd, 2003, 09:44 AM
#1
Thread Starter
Lively Member
Form_Load event: how to use??
Hi,
I have a form that is used to enter data in a database (MSAccess).
In this form the user can select different listboxes and comboboxes and the selected values are then written to the underlying database after the user has clicked the 'update'-button.
Everything works fine, but I would like to 'refresh' the form to it's original state as it was loaded after the first startup. I don't know how to do this. I tried to call the form_load event because this contains all the initialisations, but it doesn't work.
Can anybody help me with this? Please give me a code example is possible.
Many thanks,
Tom
-
Dec 3rd, 2003, 10:22 AM
#2
Frenzied Member
you need to reset each control back to the original state. You could make a routine that does that and when the user has made the final selection, call the routine in that control's event.
like this:
text1.text = ""
combobox1.text = ""
label1.text = "ready for another entry"
get it?
you just need to manually set them back like that.
It's a good idea to use a routine because that way, the user could select a button and force things back to default if he wanted to.
-
Dec 3rd, 2003, 11:02 AM
#3
Thread Starter
Lively Member
Thanks Andy,
I wrote a sub with your suggestions in it. They work fine for a combobox and a textbox but not for a listbox because the listbox should show the default startup values. How can I do this.
PS: refreshing the form with me.refresh doesn't do the job.
Thanks
Tom
-
Dec 3rd, 2003, 11:28 AM
#4
They work fine for a combobox and a textbox but not for a listbox because the listbox should show the default startup values. How can I do this.
By clearing it
ListBox1.Items.Clear()
and repopulating it the same way you did in the Form Load
-
Dec 3rd, 2003, 03:43 PM
#5
Thread Starter
Lively Member
Thanks,
I'll give it a try.
Tom
-
Dec 17th, 2003, 09:04 PM
#6
Frenzied Member
here's some code I found at VBExplorer.com
Code:
Public Sub ClearAllText(frm As Form, ctl As Control)
For Each ctl In frm
If TypeOf ctl Is TextBox Then
ctl.Text=""
End If
Next ctl
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|