DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: Clearing the form data

  1. #1
    Join Date
    Mar 2006
    Posts
    7

    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.

  2. #2
    Join Date
    Feb 2006
    Posts
    133
    Hi,

    I always use an initialize-sub to initialze my form.

    Code:
    public sub IniForm()
      ...
      form1.textbox1.text = ""
      ...
    end sub
    So everytime you need to initialize you can call the sub.
    Benjamin

  3. #3
    Join Date
    Mar 2006
    Posts
    7
    Hi Benjamin,

    I don't quite understand what you mean, what would the overall code look like for the again button then?

    Joe.

  4. #4
    Join Date
    Feb 2006
    Posts
    133
    Before the command or in the procedure of this command:

    Code:
    Call cmdenter_Click
    (what code is in it?)

    =>

    Code:
    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.
    Benjamin

  5. #5
    Join Date
    Mar 2006
    Posts
    7
    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.

  6. #6
    Join Date
    Feb 2006
    Posts
    133
    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.
    Benjamin

  7. #7
    Join Date
    Mar 2006
    Posts
    7
    yes that would work, how would I do that?

    Cheers,
    Joe

  8. #8
    Join Date
    Feb 2006
    Posts
    133
    Something like this:

    Add a new module:

    Code:
    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.
    Benjamin

  9. #9
    Join Date
    Mar 2006
    Posts
    7
    Thanks Benjamin,

    It works great now,

    Joe.

Similar Threads

  1. Replies: 0
    Last Post: 03-01-2003, 09:17 AM
  2. Replies: 2
    Last Post: 10-26-2001, 04:28 PM
  3. Q: Posting Form Data Remotely
    By J Maguire in forum ASP.NET
    Replies: 0
    Last Post: 06-05-2001, 07:06 PM
  4. data grid sub form update
    By Chuck Owen in forum VB Classic
    Replies: 1
    Last Post: 04-11-2001, 08:13 PM
  5. Replies: 0
    Last Post: 02-01-2001, 05:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center