+ Reply to Thread
Results 1 to 11 of 11

Userform to display last record on a sheet

  1. #1
    Registered User
    Join Date
    06-28-2013
    Location
    lagos, Nigeria
    MS-Off Ver
    Excel 2007
    Posts
    6

    Userform to display last record on a sheet

    hi All,

    i am a beginner in excel VBA programming, i am working on a project where the userform designed for a sheet on a workbook should display the last record whenever it is opened. and if it is opened and a new record is added in the sheet, the form should refresh and display the new record.

    Pls help

  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: Userform to display last record on a sheet

    Hello adebayo,

    Welcome to the Forum!

    The best and easiest way for us to help you is for you to post your workbook.

    To Post Your Workbook
    1. At the bottom right of the Reply window, Click the button Go Advanced
    2. At the top of the Your Message Window, in the first row of icons, Click the Paperclip icon.
    3. Click the Add Files button at the top right in the dialog box. This displays the File Manager dialog.
    4. Click the Select Files button at the bottom middle of the dialog.
    5. In the new window Find the file you want to upload, select it, and Click Open.
    6. You will now be back in the File Manager dialog. Click the bottom Middle button Upload File.
    7. Wait until the file has completely uploaded before you exit the File Manager dialog.

    File Manger Picture
    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
    Registered User
    Join Date
    06-28-2013
    Location
    lagos, Nigeria
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Userform to display last record on a sheet

    Hi Leish,

    Thks you greatly for the welcome. attached is the workbook.

    adebayo.
    Attached Files Attached Files

  4. #4
    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: Userform to display last record on a sheet

    Hello adebayo,

    I made a lot of changes to your code to condense it and make it more flexible. You should not have any problems understanding the code but if you do then please ask me for help.

    The row number is now displayed in a Label instead of a Text Box. I did this to make validation simpler. The Label has only one event - Click. There is no chance of firing another event through a code change. The Tool Tip Text will tell the user to click the label to change the row. All the buttons work. You will need to restore your SQL connection. It was necessary for me to remove it to troubleshoot the UserForm.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-28-2013
    Location
    lagos, Nigeria
    MS-Off Ver
    Excel 2007
    Posts
    6

    Thumbs up Re: Userform to display last record on a sheet

    Quote Originally Posted by Leith Ross View Post
    Hello adebayo,

    I made a lot of changes to your code to condense it and make it more flexible. You should not have any problems understanding the code but if you do then please ask me for help.

    The row number is now displayed in a Label instead of a Text Box. I did this to make validation simpler. The Label has only one event - Click. There is no chance of firing another event through a code change. The Tool Tip Text will tell the user to click the label to change the row. All the buttons work. You will need to restore your SQL connection. It was necessary for me to remove it to troubleshoot the UserForm.
    Hi Leith,

    Thanks you very much for the smart approach, i have tried it and it is displaying the last record perfectly even beyond my concept!!!,i will like to add a small dynamic unto the userform which is "To have the Userform refresh automatically whenever there is a new data from the SQL link". Presently whenever i closed the userform and reopen it the new data is displayed.
    (my link to SQL refreshes every 1 Minute)

    Rgds

    Adebayo.

  6. #6
    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: Userform to display last record on a sheet

    Hello Adebayo,

    Since the SQL link is secure, I can not be sure what is happening in the background. I will see what I can do.

  7. #7
    Registered User
    Join Date
    06-28-2013
    Location
    lagos, Nigeria
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Userform to display last record on a sheet

    Quote Originally Posted by Leith Ross View Post
    Hello Adebayo,

    Since the SQL link is secure, I can not be sure what is happening in the background. I will see what I can do.
    Hi Leith,

    Thanks, for the hope, sincere appreciation of your skills as a moderator, will patiently awaits your reply.[/There can never be a second step without the very first]

  8. #8
    Registered User
    Join Date
    06-28-2013
    Location
    lagos, Nigeria
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Userform to display last record on a sheet

    Hello Leith,

    will appreciate your solution, even if it will affect the security of the Sql link.

    Thanks in advance

    Adebayo

  9. #9
    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: Userform to display last record on a sheet

    Hello adebayo,

    Try the attached workbook. You will need to restore the SQL link as I removed it to write and test the macros.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    06-28-2013
    Location
    lagos, Nigeria
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Userform to display last record on a sheet

    hi Leith,

    thanks for the prompt action, i really appreciate your help. i opened the workbook and linked it up to SQl as instructed: following is the scenario observed whenever a new data record is added to sheet(main). The userform2 do not refresh,i can only use the NEXT button or LAST button to see the new data appearing on the form, or i have to close the form and re open before i can see the new data. what i need is to see the new data without using either the next button or LAST button or close and re open the userform2. thanks for preparing to help me further.

    Rgds

    Adebayo AJAYI

  11. #11
    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: Userform to display last record on a sheet

    Hello adebayo,

    The user form would have to be triggered by the SQL update code. That is something I can not help you with because of restricted access.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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