|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Subscript out of range VB 6 on loading a formThe message occurs as soon as a control is set on the form. ie if I rem out the line frm.lblID.Caption = "" the error occurs on the line frm.cbPO = myID This is strange because it has only just started to happen with out a code change. Any ideas greatly appreciated thanks Public Sub Show(ByRef cn As ADODB.Connection, ByRef parent As Object) Dim frm As New FrmGoodsIn Set frm.parent = parent frm.lblID.Caption = "" ----- Error message comes here --------Runtime error 9 - Subscript out of range Set frm.cn = cn PopulateCombos frm, cn frm.cbPO = myID frm.txtSupplierAccountRef.Text = GetSupplierRef(myID, cn) frm.cbPO.Enabled = False frm.CreateGRNItems frm.PopulateGRNItems frm.Show End Sub <da***@thechameleongroup.co.uk> wrote in message
Show quoteHide quote news:52c00c9b-85ed-48e5-a19f-0c5a4f424f76@j38g2000yqa.googlegroups.com... What's the Index property for lblID and cbPO set to in FrmGoodsIn?> Below is the code that runs when I try to open a form. > > The message occurs as soon as a control is set on the form. ie if I > rem out the line frm.lblID.Caption = "" the error occurs on the line > frm.cbPO = myID > > This is strange because it has only just started to happen with out a > code change. > > Any ideas greatly appreciated > > thanks > > Public Sub Show(ByRef cn As ADODB.Connection, ByRef parent As Object) > > Dim frm As New FrmGoodsIn > Set frm.parent = parent > frm.lblID.Caption = "" > ----- Error message comes here --------Runtime error 9 - Subscript out > of range > Set frm.cn = cn > PopulateCombos frm, cn > frm.cbPO = myID > frm.txtSupplierAccountRef.Text = GetSupplierRef(myID, cn) > frm.cbPO.Enabled = False > frm.CreateGRNItems > frm.PopulateGRNItems > frm.Show > > End Sub How myID was declared? Thanks for quick repsonse
Index property for lblID not set and is blank and so is cbPO Option Explicit Dim m_myID As Long Public Property Let myID(newID As Long) m_myID = newID End Property Public Property Get myID() As Long myID = m_myID End Property <da***@thechameleongroup.co.uk> wrote
> This is strange because it has only just started to happen with out a These two lines don't sit well with me:> code change. > > Any ideas greatly appreciated > frm.cbPO = myID The first line treats cbPO like a variable and the second like an object.> frm.cbPO.Enabled = False If you mean: frm.sbPO.Text = myID then use that.... See if it makes a difference ??? LFS da***@thechameleongroup.co.uk wrote in news:52c00c9b-85ed-48e5-a19f-
0c5a4f424***@j38g2000yqa.googlegroups.com: Show quoteHide quote > Below is the code that runs when I try to open a form. "Break on all errors" might help (Tools/Options/General).> > The message occurs as soon as a control is set on the form. ie if I > rem out the line frm.lblID.Caption = "" the error occurs on the line > frm.cbPO = myID > > This is strange because it has only just started to happen with out a > code change. > > Any ideas greatly appreciated > > thanks > > Public Sub Show(ByRef cn As ADODB.Connection, ByRef parent As Object) > > Dim frm As New FrmGoodsIn > Set frm.parent = parent > frm.lblID.Caption = "" > ----- Error message comes here --------Runtime error 9 - Subscript out > of range > Set frm.cn = cn > PopulateCombos frm, cn > frm.cbPO = myID > frm.txtSupplierAccountRef.Text = GetSupplierRef(myID, cn) > frm.cbPO.Enabled = False > frm.CreateGRNItems > frm.PopulateGRNItems > frm.Show > > End Sub > Most likely the error occurs in the Form_Load event of FrmGoodsIn form. Probably because you are accessing an array that hasn't yet been dimensioned, or something like that. Ian Thanks for the repsonase but no luck i am afraid
I changed the variable code to .text and tried the break on all errors but the results were the same. I put a break in the form load proceedure it runs it after the Runtime Error 9 subscript out of range message which occurs at the lines that involve setting values to controls on the form. I agree it is like the array of controls has not been built yet and thus cant access it. The strange thing is that it has only just started to happen without a code change which tells me its more likely to do with a registration of the dll or PC reason or somethign like that. The quest continues.....:-) thanks
Other interesting topics
|
|||||||||||||||||||||||