Results 1 to 2 of 2

Problem Using New Button On User Form

Threaded View

EPAIII Problem Using New Button On... 04-13-2019, 01:19 AM
6StringJazzer Re: Problem Using New Button... 04-13-2019, 09:23 AM
  1. #1
    Registered User
    Join Date
    04-13-2019
    Location
    Beaumont, TX
    MS-Off Ver
    2K Excel, Word
    Posts
    5

    Problem Using New Button On User Form

    Environment: Windows 10, Excel/Office 2K, The workbook was created over 15 years ago, probably on an earlier version of Excel: it has worked fairly well and been revised many times over that time.

    The workbook is where I keep my personal, household budget and expenses. There are sheets for each calendar year and others for other purposes, like keeping track of the charges on my individual credit cards. So when I enter a new credit card expense or convert a scheduled one to an actual credit card expense, I use a User Form which activates VBA macros to take all the steps necessary for that entry, including adding it to the appropriate sheet for that credit card. This has worked well for many years.

    This situation has come up more than once when I attempt to add a new button on this or another user form for a new credit card. First I create that new button on the user form by copying one of the existing ones and changing all the appropriate entries in it's table. Then I go to the sections of the VBA code which handle that button press and add a new "else if" condition to cover the new button. I do this by copying the existing code and just changing the name of the button. Sometimes this works but other times I get an error window pop-up that says the method is not defined or something like that.

    Here are the two sections of code where these changes were made:

    If EntryConversionForm.MCCCB Then           ' Citi Bank MC
        CCUsed = "Citi MC"
        
        ElseIf EntryConversionForm.MCCC1V Then   ' Capital One Visa
        CCUsed = "Cap1 Visa"
        
        ElseIf EntryConversionForm.MCCAE Then   ' American Express
        CCUsed = "AmEx"
        
        ElseIf EntryConversionForm.MCCBOAV Then  ' Bank of America Visa
        CCUsed = "BOA Visa"
        
        ElseIf EntryConversionForm.MCCPAE Then   ' PAE Chase MC
        CCUsed = "PAE MC"
        
        ElseIf EntryConversionForm.MCCC1PAE Then   ' PAE Chase MC
        CCUsed = "Cap1 PAE"
        
        'ElseIf EntryConversionForm.USAAV Then   ' USAA Visa 1.5%
        'CCUsed = "USAA Visa"
        
        Else
        CCUsed = ""
        MsgBox ("Credit card selected is not included in program.  No entry will be made.")
        GoTo Done
        
    End If
    and

    If EntryConversionForm.MCCCB Then           ' Citi Bank MC
        CCUsed = "Citi MC"
        CCEntryName = "Citi Bank MC (bt)"
        
        ElseIf EntryConversionForm.MCCC1V Then   ' Capital One Visa
        CCUsed = "Cap1 Visa"
        CCEntryName = "CapOne Visa (bt)"
        
        ElseIf EntryConversionForm.MCCAE Then   ' American Express
        CCUsed = "AmEx"
        CCEntryName = "AmEx (bt)"
        
        ElseIf EntryConversionForm.MCCBOAV Then   ' Bank of America Visa
        CCUsed = "BOA Visa"
        CCEntryName = "Bank of America xxxx (bt)"
        
        ElseIf EntryConversionForm.MCCPAE Then   ' PAE Chase MC
        CCUsed = "PAE MC"
        CCEntryName = "Chase MC/PAE (bt)"
        
        ElseIf EntryConversionForm.MCCC1PAE Then   ' Capital One PAE
        CCUsed = "CAP1 PAE"
        CCEntryName = "Cap1 PAE Visa (bt)"
        
        'ElseIf EntryConversionForm.USAAV Then   ' USAA Visa 1.5%
        'CCUsed = "USAA Visa"
        'CCEntryName = "USAA Visa (bt)"
        
        Else
        CCUsed = ""
        MsgBox ("Credit card selected is not included in program.  No entry will be made.")
        GoTo Done
        
    End If
    The added lines are commented out as they were not working. The macro works perfectly for all the other credit card buttons on the user form.

    OK, now here is the "kicker", yesterday, when I created the new additions they did not work. Excel even crashed when I was trying to work on them. But today, while writing this post, I reactivated the new lines of code and they worked perfectly. Nothing has changed except to remove the exclamation points at the beginning of each line so that the code would be used. I made a quick test and it converted the entry perfectly: the amount of the credit card transaction was added to that sheet just as it should have been.

    Can anyone tell me what is going on here? I would really love to understand the use of VBA objects better. This button is a VBA object, isn't it? Or have i committed some syntax error? And what can I do the next time to avoid this difficulty?
    Last edited by EPAIII; 04-13-2019 at 01:22 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Add Search Button in User Form
    By M. Shahbaz in forum Excel General
    Replies: 2
    Last Post: 06-10-2017, 05:09 AM
  2. [SOLVED] OK button in user form
    By twckfa16 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 09-22-2015, 05:40 PM
  3. [SOLVED] User-Form Problem: User can select headers in User Form (I want Header/no way to select)
    By navialivad in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-18-2014, 10:24 AM
  4. [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
  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. User Form button
    By lapot in forum Excel General
    Replies: 0
    Last Post: 06-07-2007, 06:06 AM
  7. User form x button
    By Greg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2006, 12:00 PM

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