-
I am getting a baffling error in a program I am working on. It is not the error itself but when it is occurring.
The error I am getting is “Object doesn’t support property or method.” And I get an OK or Help option….If I press OK the program continues on normally.
It is not a run-time error that can be debugged or even trapped it seems to be a VB error. The problem is it happens at random times and in no set pattern…when I break into code (ctrl-break) all the objects are set to valid properties and are using valid methods. I am at a loss.
Is there anyway to suppress this message? I have tried on error resume next statements to no avail….any suggestions?
-
<?>
everything has a reason...
is it small enough to post code?
-
This happened to me once also. I forgot to set a reference to the Objetc Model I wanted to use. At least thats what I think... I set the reference and it worked without the error, but I did'nt fully understand the error so am not 100% sure that sorted it or some other 'hack' sorted it.
I am a poor programmer and sometimes change more than 1 thing at a time ;)
-
OK I found the line that is giving me trouble...it in in one of my classes that I am using to control a database interface screen.
the line is
Code:
If mvarTotalRecords > 0 Then
mvardataCtl.Recordset.AbsolutePosition = mvarSliderBar.Value - 1
updateButtons
End If
mvardatacontrol is a Data object
mvarSliderBar is a Slider
both are set on Form_load to their respective objects.
UpdateButtons is a proceedure in the class to handle the enabling and disabling of buttons.
The strange thing is the error doesnt always happen....this proceedure is called by moving or clicking on the sliderbar and only happens at random times.
-
Could it be that mvarSliderBar.Value gets to be less than zero somehow? If it did then you would get that error message when you tried to set AbsolutePosition to a negative value.
-
msgbox "mvardataCtl.Recordset.AbsolutePosition"
msgbox "mvarSliderBar.Value - 1"
or debug...see which one has the problem.
-
Yep I tried doing that and every single time I get the error both values of mvardataCtl.Recordset.AbsolutePosition and mvarSliderBar.Value - 1 are valid.
And the objects are valid as well. Going to have a look elsewhere...guess I will comment out all code till I find the offending line.
Thanks all for the help....if you can think of anything else or you had this error before and know how to fix it please let me know...thanks :)