View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Runtime Error 381 - Invalid Property Array

Hi Mark,

Not certain this is the answer your second question but I think that in
making changes to the object with code then that change is recognized and the
change event code triggers. Try inserting
Application.EnableEvents = False just before clearing the values and then
after that code has run insert Application.EnableEvents = True.

Now a warning when using this code. If your code fails due to error before
turning events back on then the events remain off until you restart Excel or
use code to turn events back on. (This can occur during testing or other time
due to unforseen code problems). Set up a sub as follows and you can just run
it from the VBA editor if required.

Sub Re_EnableEvents()
Application.EnableEvents = True
End Sub

If you use error routines then you should always call this sub in the error
routine.



--
Regards,

OssieMac


" wrote:

Hello All,

{Excel 2007, PC, novice}

I have a userform which contains a ComboBox showing the bound column
data.
It supplies two Text boxes with data from the two columns not shown.


----'Text Box Values will reflect Credit Card Choice

Private Sub cmb_Purch_CreditCard_Change()
txt_Purch_SecCode = Me.cmb_Purch_CreditCard.Column(1)
txt_Purch_CodeLoc = Me.cmb_Purch_CreditCard.Column(2)
End Sub

======================================

The ComboBox Enabled property is set to False ,and the row source is
set to a range on a lookup sheet - only to be activated when the user
chooses the Credit Card method of payment. This allows Credit Card
related info to be visible and data to be entered into other text
boxes.

----'Activate Credit Card ComboBox

Private Sub cmb_PaymentMethod_Change()

If cmb_PaymentMethod.Value = "CC" Then
cmb_Purch_CreditCard.Enabled = True
cmb_Purch_CreditCard.BackColor = &H80000005

Else: cmb_Purch_CreditCard.Enabled = False
cmb_Purch_CreditCard.BackColor = &H8000000B
End If
End Sub

===================================

Adding the data to the spreadsheet works fine (relevant code shown):.


----'Payment Methods
..Cells(lRow, 24).Value = Me.cmb_PaymentMethod.Value
..Cells(lRow, 25).Value = Me.cmb_Purch_CreditCard.Value
..Cells(lRow, 26).Value = Me.txt_Purch_SecCode.Value
..Cells(lRow, 27).Value = Me.txt_Purch_CCExpire.Value

================================================

When I run a Command button to €˜Clear Form but not close the form, I
receive a €˜Runtime error 381 Could not get the column property.
Invalid property array. The button and the code are located on/in
the user form, not in a module


Rather than flowing through this code in the Sub for €˜Clear
Form (relevant code shown):

---'Clear Payment Methods
cmb_PaymentMethod.Value = ""
cmb_Purch_CreditCard.Value = ""
txt_Purch_CCExpire.Value = ""
txt_Discounts.Value = ""
txt_Notes.Value = ""

The code jumps out and goes to the second line of the other Sub
routine:


---'Text Box Values will reflect Credit Card Choice

Private Sub cmb_Purch_CreditCard_Change()
txt_Purch_SecCode = Me.cmb_Purch_CreditCard.Column(1)
txt_Purch_CodeLoc = Me.cmb_Purch_CreditCard.Column(2)
End Sub



Does this need to be in the module for intializing the form?

I'm learning this as I go along, but Im at a loss trying to figure
this one out.

Any ideas?
Thanks!

Mark Mace