Clearing the form data
Hey,
I have created a program that takes in various details and prints them onto the form with the appropriate tabulation. This works fine, however when I reach the final screen with all details appearing on the form and I click on the command button which I created to re-enter data the new data is not appearing. Is there any way to clear the form of all data when clicking on the re enter button to allow the newer data to be displayed?
The code I used for the re enter command button is:
Private Sub menuagain_Click()
'this procedure allows the user to enter another set of details.
Dim reply As Integer
reply = MsgBox("Are you sure you want to enter a new set of data?", vbQueston + vbYesNoCancel, "Enter again")
If reply = vbYes Then
Call cmdenter_Click
End If
End Sub
Cheers,
Joe.
[877 byte] By [
joejdx] at [2007-11-11 8:09:33]

# 1 Re: Clearing the form data
Hi,
I always use an initialize-sub to initialze my form.
public sub IniForm()
...
form1.textbox1.text = ""
...
end sub
So everytime you need to initialize you can call the sub.
# 2 Re: Clearing the form data
Hi Benjamin,
I don't quite understand what you mean, what would the overall code look like for the again button then?
Joe.
joejdx at 2007-11-11 17:26:51 >

# 3 Re: Clearing the form data
Before the command or in the procedure of this command:
Call cmdenter_Click
(what code is in it?)
=>
IniForm
Call cmdenter_Click
In the IniForm sub you define every field of the form to "" or something else, it depends on what fields you have of course.
Basically the idea is to call a seperated sub who initializes the fields of the form. It 's just a global thought, I don't know what your total code is of course.
# 4 Re: Clearing the form data
Hi Benjamin,
I understand what you mean now, and it is a good way to do it, however it is not a textbox that I am using, the program is printing the information directly onto the form without an extra lable or text box, so how would this work for the form itself?
Joe.
joejdx at 2007-11-11 17:28:54 >

# 5 Re: Clearing the form data
I'm not sure what method you use to print the data on the form...
Another idea is to call a public sub(outside the form module) who unloads the form and then loads the form, so the form is clean again.
# 6 Re: Clearing the form data
yes that would work, how would I do that?
Cheers,
Joe
joejdx at 2007-11-11 17:31:05 >

# 7 Re: Clearing the form data
Something like this:
Add a new module:
Option Explicit
Public Sub IniForm()
Unload Form1 'Unload the form
Form1.Show 'Show the form
End Sub
In your form-code use IniForm to call it.