+ Reply to Thread
Results 1 to 3 of 3

Previous / Next Record Buttons Code Question

  1. #1
    Forum Contributor
    Join Date
    09-29-2014
    Location
    Montreal, Canada
    MS-Off Ver
    2013
    Posts
    222

    Previous / Next Record Buttons Code Question

    The code below is from a lesson I follow and trying to understand how it works I can’t see where the “Controls” and “Control” words belongs to. The Me.Control1 belongs to a text box and there are 6 similar text boxes numbered Control1 to 6. Perhaps the “Controls” and “Control” words are part of the Excel VBA internal commands?

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Previous / Next Record Buttons Code Question

    Hell oskar44,

    Controls is a collection object belonging to the UserForm. Any object you add to the UserForm at design time is added to this collection.

    Collection objects can be referenced 2 ways: by creation Index number or by a key. A key is unique string that identifies the item in the collection.
    For example, let's say our UserForm has a label, text box, and command button and the order of creation was command button, label, and then the textbox.

    The items in the UserForm Controls collection can be referenced by Index: Controls(1) = "CommandButton1", Controls(2) = "Label1", and Controls(3) = "TextBox1"
    or by key like this: Controls("CommandButton1"), where the Collection key is the object's name.

    Your lesson made a bad choice of renaming "TextBox1" as "Control1". Now, you have no idea what this control is supposed to do on the UserForm when you are looking at the code. Control is not a reserved word and can used as either the name of a variable or object in VBA.

    On a personal note, you would do better asking us for help This lesson is was not written by a VBA expert.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    09-29-2014
    Location
    Montreal, Canada
    MS-Off Ver
    2013
    Posts
    222

    Re: Previous / Next Record Buttons Code Question

    Thank you Leith for your time and good explanation

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Userform Edit Record and GoTo record Command Buttons
    By 139runner in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 04-30-2020, 12:54 AM
  2. Replies: 1
    Last Post: 11-16-2012, 09:25 AM
  3. Command Buttons for Viewing Record, Next Record and Previous Record
    By david1987 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-23-2012, 06:30 AM
  4. Create Next /Previous command buttons also Modify existing record in a Userform
    By rabalam in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-05-2012, 04:10 PM
  5. auto populate a record based upon a value in previous record.
    By leewcrawford in forum Access Tables & Databases
    Replies: 4
    Last Post: 04-07-2009, 11:41 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1