+ Reply to Thread
Results 1 to 24 of 24

User Form VBA - Complie Error in cmd button

  1. #1
    Registered User
    Join Date
    07-06-2015
    Location
    Phoenix , AZ
    MS-Off Ver
    2010
    Posts
    47

    Unhappy User Form VBA - Complie Error in cmd button

    OK, this time I hope this is the last time today I have to keep posting and I appreciate all the help I've been receiving but again I am new at VBA and I coded a cmd button to go to previous record and I keep getting an compile error -Syntax error and the top line is highlighted.

    Please Login or Register  to view this content.
    Any help please

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: User Form VBA - Complie Error in cmd button

    Try this..
    Please Login or Register  to view this content.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Registered User
    Join Date
    07-06-2015
    Location
    Phoenix , AZ
    MS-Off Ver
    2010
    Posts
    47

    Re: User Form VBA - Complie Error in cmd button

    Thank you I did it and I received no error but the command button does nothing I keep pressing the button and the records do not move and no error comes up.

    Please Login or Register  to view this content.
    [/CODE]

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: User Form VBA - Complie Error in cmd button

    The variable lcurrentrow is not initialized, so its value is 0.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    07-06-2015
    Location
    Phoenix , AZ
    MS-Off Ver
    2010
    Posts
    47

    Re: User Form VBA - Complie Error in cmd button

    Forgive me for I am a newbie with VBA but when you "not initialized" What do you mean?

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: User Form VBA - Complie Error in cmd button

    It's not assigned a value before it's tested.

  7. #7
    Registered User
    Join Date
    07-06-2015
    Location
    Phoenix , AZ
    MS-Off Ver
    2010
    Posts
    47

    Re: User Form VBA - Complie Error in cmd button

    Well here is another newbie question how do I assigned a value to it ?

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: User Form VBA - Complie Error in cmd button

    What is it supposed to represent?

  9. #9
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: User Form VBA - Complie Error in cmd button

    Try this code
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  10. #10
    Registered User
    Join Date
    07-06-2015
    Location
    Phoenix , AZ
    MS-Off Ver
    2010
    Posts
    47

    Re: User Form VBA - Complie Error in cmd button

    OK, So I took the code above but i get errors and I think its becasue I already have an Update and next record code . I also did change wording in my code which is below and now it runs and no error but when I go to press the command button it does nothing??


    Please Login or Register  to view this content.
    Hmmmmmm

  11. #11
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: User Form VBA - Complie Error in cmd button

    What is it that you are trying to do?
    I mean all you say is you get an error but what are you actually trying?
    You never add a row only subtract a row so it never moves.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  12. #12
    Registered User
    Join Date
    07-06-2015
    Location
    Phoenix , AZ
    MS-Off Ver
    2010
    Posts
    47

    Re: User Form VBA - Complie Error in cmd button

    I am trying to make a command button to go to previous record in my user form and when I run the form it goes but when I go to hit the command button with the code below it does nothing not sure what I am doing wrong?


    Please Login or Register  to view this content.

  13. #13
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: User Form VBA - Complie Error in cmd button

    Try this
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    07-06-2015
    Location
    Phoenix , AZ
    MS-Off Ver
    2010
    Posts
    47

    Re: User Form VBA - Complie Error in cmd button

    I tried it and when I go to run the command button I just get a "Now you are in the header row" and the form does nothing.

  15. #15
    Registered User
    Join Date
    07-06-2015
    Location
    Phoenix , AZ
    MS-Off Ver
    2010
    Posts
    47

    Re: User Form VBA - Complie Error in cmd button

    Not sure if it matters but I have a second command button which is Next Record and t goes to the next record in my user form it is below
    This code works for next record
    Please Login or Register  to view this content.



    This code does not work trying to go to PREVIOUS record
    Please Login or Register  to view this content.

    I am trying to get the second code to work?? Please

  16. #16
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: User Form VBA - Complie Error in cmd button

    Hi cardonas
    Did you try the code in post #9?
    It would deal with the two cases for you: next and previous record

  17. #17
    Registered User
    Join Date
    07-06-2015
    Location
    Phoenix , AZ
    MS-Off Ver
    2010
    Posts
    47

    Re: User Form VBA - Complie Error in cmd button

    I did but I think I know what I did wrong I put the whole code in together and not separate also I kept my other next record code as well so I am not sure but I am going to try it again I have two command buttons one "Next " and other coded "Previous" So I am assuming taking the code from post #9 and separating it???? going to try it now

  18. #18
    Registered User
    Join Date
    07-06-2015
    Location
    Phoenix , AZ
    MS-Off Ver
    2010
    Posts
    47

    Re: User Form VBA - Complie Error in cmd button

    I am a little confuse on how to put the code below in ?? I already have an " next record" command button that works and I also have an "initialize form code as well" With the code below do I separate it and replace my codes I have now?

    Please Login or Register  to view this content.

  19. #19
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: User Form VBA - Complie Error in cmd button

    Just try in another copy of your file the code for both commanbuttons (cmdNextRecord & cmdPreviousRecord) ..
    Put the whole code I posted in your userform module

  20. #20
    Registered User
    Join Date
    07-06-2015
    Location
    Phoenix , AZ
    MS-Off Ver
    2010
    Posts
    47

    Re: User Form VBA - Complie Error in cmd button

    I was just about to write back I did it and it work but now there another problem my update command button not updating records and all my text boxes are pulling the headers as well records from my worksheet. I just now need to fix my update command button.
    And again you're awesome!!! I appreciate the help

  21. #21
    Registered User
    Join Date
    07-06-2015
    Location
    Phoenix , AZ
    MS-Off Ver
    2010
    Posts
    47

    Re: User Form VBA - Complie Error in cmd button

    I just realzie I need to put my code back for updating my records I will see if it works once I put it in.

  22. #22
    Registered User
    Join Date
    07-06-2015
    Location
    Phoenix , AZ
    MS-Off Ver
    2010
    Posts
    47

    Re: User Form VBA - Complie Error in cmd button

    Thank you again YasserKhalil!! Again like always you are a genius!!!

  23. #23
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: User Form VBA - Complie Error in cmd button

    You're welcome. Glad I can offer help
    Thanks for the feedback
    Regards

  24. #24
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: User Form VBA - Complie Error in cmd button

    Well, patience did deliver

+ 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. [SOLVED] User Form - Hyperlink Button within a Form, to create a Link on a Designated Cell
    By Sinalk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2013, 07:29 AM
  2. [SOLVED] Complie error : else without if?
    By soldout2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-26-2013, 07:55 AM
  3. [SOLVED] Command Button to Call User Form - Run Time Error 1004
    By CRIMEDOG in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-12-2013, 11:27 AM
  4. Receiving following error “Complie error : syntax error” Help
    By masond3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-02-2012, 10:19 AM
  5. VBA User Form - Linking Close Button and Cancel Button
    By nivassrii in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-26-2011, 07:05 AM
  6. Complie error: End If without If
    By Seler Naciowy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-01-2008, 06:49 AM
  7. [SOLVED] VB Complie error - can You Help
    By Anthony in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2005, 06:05 PM
  8. Complie Error Help
    By JMay in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-24-2005, 01:06 AM

Tags for this Thread

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