PDA

View Full Version : Bypass code



av8tordude
05-26-2011, 11:06 AM
How can I bypass the code highlighted in red if the frmReceipt was not called?

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")

CharlesH
05-26-2011, 12:23 PM
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

av8tordude
05-26-2011, 12:31 PM
Thank you Charles. Your suggestion worked.:beerchug:

CharlesH
05-26-2011, 12:33 PM
Thanks for letting me know.