I keep getting this runtime error 91..
"Object variable or With block variable not set"
what does it mean?
I keep getting this runtime error 91..
"Object variable or With block variable not set"
what does it mean?
with what are you getting it, a variable, or control, or what?
I usually get that when i haven't set a variable with the Set keyword. For example the DataSource for many controls has to be done like so;If you just putCode:Set Moo.DataSource = Whatever
it moans with that error.Code:Moo.DataSource = Whatever
heres my code:
I get the error at GetSelectedPath = p_CurNode.Key & "\" & p_CurItem.TextCode:If TypeOf p_CurControl Is ListView Then
'
'if active control is listview
'
If p_CurItem.Icon = 4 Then
'
'If selected item is folder
'
GetSelectedPath = p_CurNode.Key & "\" & Right$(p_CurItem.Text, Len(p_CurItem.Text) - 1)
Else
'
'if selected item is shortcut
'
GetSelectedPath = p_CurNode.Key & "\" & p_CurItem.Text
End If
Else
'
'If active control is treeview
'
GetSelectedPath = p_CurNode.Key
End If
if i try msgbox p_curnode.key, i still get the same error.. This isnt my code, im just messin with someone elses :)
This means that you have created a variable that refers to an object, that doesn't exist...
For example:
Code:Dim fnt As StdFont
Private Sub Form_Load()
Set fnt = New StdFont 'When you leave this line, vb tries to do the next line with 'Nothing'
fnt.Name = "Arial"
End Sub
You get this if you try to use a variable, but haven't told VB what the variables equal to :
Will work, but in the below, I've just declared the variable, & not set a value to it so VB doesn't know what on earth tho returnCode:Dim AString as String
AString = "Hello World"
MsgBox AString
(and sorry for using a Hello World example :D) :
Code:Dim AString as String
MsgBox AString
Hi toghether !!!
Sorry for my dump question, do you have compiled your project ?
Because this error message happend often to me, if I forgot an "endif, ....", in a with statement.
Note; the rror must not be in the same module
-cu TheOnly
Actually Alex your answer will work, assuming the declaration is a typo ( you missed the 'r' in string). A string is initialised to "" when it's declared so you can use it, it'll just be blank. The error we're talking about here is specific to an object. That's because an object is just a pointer to a block of memory but if it's not set then it literally points at nothing and VB doesn't know what to do. Hence this error. TheOnly's example illustrates the other time you will get this message.
Sooo, one of the objects in the original code must not be set. See my earlier reply to see how to check this out.
Sorry to be a smart arse but I thought you might like to know the above.
Anti-smartie pants note : All variables are actually pointers to a bit of memory where the value is held BUT VB does not initialise an object's memory space for you.
;)
Point taken, didn't test this one anyway.
with my posts, you can guarantee it's always a typo & I constantly go back into my posts to change words :rolleyes: - this is ammended!
Is that why your post count is that big?? :rolleyes:Quote:
Originally posted by alex_read
;)
Point taken, didn't test this one anyway.
with my posts, you can guarantee it's always a typo & I constantly go back into my posts to change words :rolleyes: - this is ammended!
j/k
.
Nah, these ones I'm talking about is me going into the already posted answers & ammending them.
Yeah, but RDO stands for Remote Data Objects. + 1