Results 1 to 4 of 4

Thread: VBA Controls

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    263

    Question

    I am using a form in Mic. Excel. On the form, it contains CheckBoxes, TextBoxes, ComboBoxes, and CommandButtons. What I am trying to do is make a button so when the user clicks it, it will reset the whole form. I.E. Clear all the checkboxes, comboboxes, and textboxes. Well, it works but not exactly. What it does is every time you click the button, it clears one object. So, you have to keep clicking the button, clearing one object at a time until the form is clear. What am I doing wrong? Here is the code I am usin:
    This is one set of code I tried:
    cbxEmployeeName.Text=blank
    ccbxSeries6.Value=False
    ctxtFirstName.Text=blank

    Then I tried another set of code and it does the same

    With frmReferral
    .cbxEmployeeName.Text=""
    .ccbxSeries6.Value=False
    .ctxtFirstName.Text=""


    Am I doing something wrong???
    Someone please help me. I will even send you the form and let you look at it.
    Thanks Alot,

    David Gottlieb
    CIW Certified Internet Webmaster
    Web Developer/Designer

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Could you send it to me?

    [email protected]
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    New Member
    Join Date
    Aug 2000
    Posts
    8
    I suggest that you create a collection for each groug of CheckBoxes, TextBoxes, ComboBoxes, and CommandButtons.

    'The following goes in the declaration portion of the userform and initiates a collection

    Public colTextBox As New Collection

    'The following code populates the collection
    'can be used during the initialize event
    'Add Command Buttons to colTest collection
    For Each Control In UserForm1.Controls()
    If Mid(Control.Name, 1, 3) = "cmd" Then
    UserForm1.colTextBox.Add Control.Name
    End If
    Next Control

    'The following code can be used to clear the textboxes
    For Each myObject In UserForm1.colTextBox()
    UserForm1(myObject).Caption = ""
    Next
    Vin Lis

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169

    Talking Watch the post dates

    Thanks for the help, but I think we fixed this a while ago !
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width