Consulting

Results 1 to 4 of 4

Thread: Bypass code

  1. #1

    Bypass code

    How can I bypass the code highlighted in red if the frmReceipt was not called?
    [vba]
    Range("Expense").Cells(Table, 1) = Application.Max(Range("AU11:AU500")) + 1
    Range("Expense").Cells(Table, 2) = CDate(Date5)
    Range("Expense").Cells(Table, 3) = cboCat.Value
    Range("Expense").Cells(Table, 4) = cboDesc.Value
    Range("Expense").Cells(Table, 5) = CCur(Amnt)
    Range("Expense").Cells(Table, 6) = frmReceipt.txtReceipt.Value
    Range("Expense").Cells(Table, 7) = frmReceipt.txtName.Value
    Range("Expense").Cells(Table, 8) = frmReceipt.txtCity.Value & ", " & frmReceipt.txtState.Value
    Range("Expense").Cells(Table, 9) = Format(frmComp.Comp, "$0.00")
    [/vba]

  2. #2
    VBAX Regular
    Joined
    Oct 2010
    Posts
    73
    Location
    Hi,

    You can set a boolean that when the userform is call to set the boolean to True and with in the code. In a Module use "Public MyForm as Boolean".
    With in the Form code you set MyForm = True.
    After the code below runs you set the MyForm to False


    Range("Expense").Cells(Table, 1) = Application.Max(Range("AU11:AU500")) + 1 
    Range("Expense").Cells(Table, 2) = CDate(Date5) 
    Range("Expense").Cells(Table, 3) = cboCat.Value 
    Range("Expense").Cells(Table, 4) = cboDesc.Value 
    Range("Expense").Cells(Table, 5) = CCur(Amnt) 
    If MyForm = true then
       Range("Expense").Cells(Table, 6) = frmReceipt.txtReceipt.Value 
       Range("Expense").Cells(Table, 7) = frmReceipt.txtName.Value 
       Range("Expense").Cells(Table, 8) = frmReceipt.txtCity.Value & ", " &    frmReceipt.txtState.Value 
       Range("Expense").Cells(Table, 9) = Format(frmComp.Comp, "$0.00") 
    end if
    MyForm = False
    My Time is valuable. The forum's time is valuable.
    So take time to say "Thanks"

    As with all programs there may be an easier way!
    CharlesH

  3. #3
    Thank you Charles. Your suggestion worked.

  4. #4
    VBAX Regular
    Joined
    Oct 2010
    Posts
    73
    Location
    Thanks for letting me know.
    My Time is valuable. The forum's time is valuable.
    So take time to say "Thanks"

    As with all programs there may be an easier way!
    CharlesH

Posting Permissions

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