+ Reply to Thread
Results 1 to 11 of 11

Form button on click event not trigerring

  1. #1
    Registered User
    Join Date
    10-02-2012
    Location
    karachi
    MS-Off Ver
    Excel 2007
    Posts
    28

    Form button on click event not trigerring

    I have four different forms for separate purpose. I create another form that takes employee ID as input. Update other info using button "GetInfo". then save.
    Save button finds the id in a table and update the time in E column of that table in front of that ID. The code was working fine when run as macro. But when i change it to form, its just not working. nor giving any error.
    its just not going in IF loop. but if I enter an invalid employee id like "a" in textbox1, it says, employee absent today.
    EMployee ID format is E1, E2, E3 ....

    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: Form button on click event not trigerring

    Hello Umair.711,

    My best guess is that the object variable rngFound is set to Nothing indicating that what you are looking for was not found.

    Have you tried stepping through the macro and checking the variables?
    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
    10-02-2012
    Location
    karachi
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Form button on click event not trigerring

    Quote Originally Posted by Leith Ross View Post
    Hello Umair.711,

    HeMy best guess is that the object variable rngFound is set to Nothing indicating that what you are looking for was not found.

    Have you tried stepping through the macro and checking the variables?
    hey Leith,

    i changed the code a bit and move set rngFound=nothing in else statement. put a msgbox in there to show where it is. but nothing shows up.

    Please Login or Register  to view this content.

  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: Form button on click event not trigerring

    Hello Umair.711,

    You should post a copy of the workbook that I can run myself and troubleshoot the problem.

    If your workbook contains any sensitive information, please redact that information before you post.

    How 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.

  5. #5
    Registered User
    Join Date
    10-02-2012
    Location
    karachi
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Form button on click event not trigerring

    well there is nothing in there yet.. I hope there will be, sometime later.

    hotel.xlsb

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Form button on click event not trigerring

    Umair.711

    The code is being triggered, so if it's not doing what you want it to then the problem must be in the code itself.

    As well as Leith's suggestion of stepping through the code it's probably a good idea to remove/comment On Error Resume Next.

    Another thing you might want to look at is what's actually in the variables strDay and day2 and how their values compare to the values on the worksheet you are trying to match them with.
    If posting code please use code tags, see here.

  7. #7
    Registered User
    Join Date
    10-02-2012
    Location
    karachi
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Form button on click event not trigerring

    Quote Originally Posted by Norie View Post
    Umair.711

    The code is being triggered, so if it's not doing what you want it to then the problem must be in the code itself.

    As well as Leith's suggestion of stepping through the code it's probably a good idea to remove/comment On Error Resume Next.

    Another thing you might want to look at is what's actually in the variables strDay and day2 and how their values compare to the values on the worksheet you are trying to match them with.
    I used this code in a simple macro first. And strDay and day2 were working good in macro. But my requirement is for the form. I displayed them and they are proper dates in format MMM/DD/YYYY. The format is same as the format of column A data.

  8. #8
    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: Form button on click event not trigerring

    Hello Umair.711,

    I corrected several errors in your code. This version ran for me with no problems. Try it out and let me know the results,

    Please Login or Register  to view this content.

  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: Form button on click event not trigerring

    Hello Umair.711,

    I corrected several errors in your code. This version ran for me with no problems. Try it out and let me know the results,

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    10-02-2012
    Location
    karachi
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Form button on click event not trigerring

    Quote Originally Posted by Leith Ross View Post
    Hello Umair.711,

    I corrected several errors in your code. This version ran for me with no problems. Try it out and let me know the results,

    Please Login or Register  to view this content.
    Great job. You are a genius.. Thanks (y)

  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: Form button on click event not trigerring

    Hello Umair.711,

    If you don't have any more questions about this problem or it's solution, I will mark this post solved.

+ 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. button click event
    By tmill29 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-18-2014, 09:44 PM
  2. Call button click event from a button on anther sheet
    By ajaykgarg in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-25-2010, 09:27 AM
  3. Add Code To Button Click Event Using VBA
    By chergh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2009, 06:24 AM
  4. [SOLVED] Command Button - On Click Event
    By sharonm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-27-2006, 08:20 AM
  5. event with commandbar button right-click?
    By RB Smissaert in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-13-2005, 09:05 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