-
August 18th, 2006, 03:25 PM
#1
Run-time error '91': Object variable or With block variable not set
I get this error and have no idea how to solve it. I have been reading several treads on this forum abut this error but i cannot solve it.
This is the start of my program:
Dim Temp As Variant
Dim AantalRec As Integer
Dim oRoot As IXMLDOMElement
Dim oElemVN As IXMLDOMElement
Dim oElemBericht As IXMLDOMElement
Dim oElemAdministratieveEenheid As IXMLDOMElement
Dim oElemTijdvakAangifte As IXMLDOMElement
Dim oElemTijdvakCorrectie As IXMLDOMElement
Dim oElemVolledigeAangifte As IXMLDOMElement
Dim oElemCollectieveAangifte As IXMLDOMElement
Dim oElemSaldoCorrectiesVoorgaandTijdvak As IXMLDOMElement
Dim oElemInkomstenverhoudingInitieel As IXMLDOMElement
Dim oElemNatuurlijkPersoon As IXMLDOMElement
Dim oElemAdresBinnenland As IXMLDOMElement
Dim oElemAdresBuitenland As IXMLDOMElement
Dim oElemInkomstenPeriode As IXMLDOMElement
Dim oElemSectorRisocogroep As IXMLDOMElement
Dim oElemNominatieveAangifte As IXMLDOMElement
Dim OElemWgf As IXMLDOMElement
Dim oElemData As IXMLDOMElement
Dim oElemDataChild As IXMLDOMElement
Dim oDocType As IXMLDOMDocumentType
Dim intIDX As Integer
Dim strXMLInstruct As String
Dim oAttribute As IXMLDOMAttribute
Dim oRootElem As IXMLDOMElement
Dim oRootLoonAangifte As IXMLDOMElement
' Dim Opi As IXMLDOMProcessingInstruction
Dim Tempbedrag As Single
Dim Bedrag As Long
Dim Bedrag1 As Single
When running the program, the first part is doing good.
But on this line:
oElemTijdvakCorrectie.appendChild oElemInkomstenverhoudingInitieel
i get the error.
Who can help me?
Regards,
Herman
-
August 18th, 2006, 03:45 PM
#2
Re: Run-time error '91': Object variable or With block variable not set
Could be that you are trying to reference a non-existent object. Are you sure that you have all the spelling right? That is a lot of characters. German is it?
Take a look at the following URL.
http://msdn2.microsoft.com/en-us/library/5szkzs17.aspx
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
August 18th, 2006, 04:54 PM
#3
Re: Run-time error '91': Object variable or With block variable not set
No Peejavery, it is Dutch. (Holland). I am sure that the spelling is correct. I had already seen that URL. It did not help.
Thanks for your reaction.
Herman
-
August 18th, 2006, 05:19 PM
#4
Re: Run-time error '91': Object variable or With block variable not set
Could you attach the form that contains that object?
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
August 19th, 2006, 04:19 AM
#5
Re: Run-time error '91': Object variable or With block variable not set
Aren't you missing this line
Code:
Set oElemTijdvakCorrectie = New IXMLDOMElement
You cannot reference something that has not been initialized. And to initialize an Object you need to use the New Keyword.
-
August 19th, 2006, 04:32 AM
#6
Re: Run-time error '91': Object variable or With block variable not set
Thanks Shuja Ali.
I placed that statement under the dim-statements and get an error:
'Invalid use of New keyword'.
Could you please tel me what i am doing wrong?
Dim oRootElem As IXMLDOMElement
Dim oRootLoonAangifte As IXMLDOMElement
>> Set oElemTijdvakCorrectie = New IXMLDOMElement
Thans in advance.
Herman
-
August 19th, 2006, 04:48 AM
#7
Re: Run-time error '91': Object variable or With block variable not set
Oh sorry for the previous post. That just came out of my mind directly. Anyaways, you need to learn the basidcs of how MS XML3 Parser works. Take a look at this article
http://www.xml.com/pub/a/2000/07/12/...b_and_xml.html
Now regarding your problem, you need to understand that the DOMElement belongs the DOMDocument. So without referecing a DOMDocument you cannot access the Element. Take a look at this sample
http://vb-helper.com/howto_build_for..._xml_file.html
-
August 20th, 2006, 04:47 AM
#8
SOLVED Re: Run-time error '91': Object variable or With block variable not set
Hi,
My problem is solved:
The wrong line should be:
Set oElemInkomstenverhoudingInitieel = oDOM.createElement("InkomstenverhoudingInitieel")
oElemTijdvakCorrectie.appendChild oElemInkomstenverhoudingInitieel
Thanks everybody for the help.
Greetings,
Herman
-
September 11th, 2009, 12:40 AM
#9
Re: Run-time error '91': Object variable or With block variable not set
Hi,
I have done one small project in vb using access, emp master data, bu i'm getting a error " Run-time error '91': Object variable or With block variable not set"
here my code :
Private Sub cb_save_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set rs = db.OpenRecordset("select * from EMPICPL")
If tb_desig.Text = "" Then
MsgBox "PLEASE ENTER EMPLOYE NAME"
tb_desig.SetFocus
Else
If tb_subd.Text = "" Then
MsgBox "ENTER EMPLOYE ADDRESS"
tb_subd.SetFocus
Else
If tb_basic.Text = "" Then
MsgBox "ENTER EMPLOYE TALUKA"
tb_basic.SetFocus
Else
'EMPLOYE CODE GENARATION
If rs.EOF = False And rs.BOF = False Then
rs.MoveFirst
While (Not rs.EOF)
txtempcode.Text = rs!EMP_CODE
rs.MoveNext
Wend
txtempcode.Text = Val(txtempcode.Text) + 1
End If
If txtempcode.Text = "" Then
txtempcode.Text = "1"
End If
rs.AddNew
rs!desig = tb_desig.Text
rs!SUbDepartment = tb_subd.Text
rs!Basic = tb_basic.Text
rs!EMP_CODE = txtempcode.Text
rs.Update
rs.Close
txtempcode.Text = ""
tb_desig.Text = ""
tb_subd.Text = ""
tb_basic.Text = ""
End If
End If
End If
End Sub
please anyone can help me.
thanks & regards
vijay
-
September 11th, 2009, 06:31 PM
#10
Re: Run-time error '91': Object variable or With block variable not set
This is a thread about XML. I suggest that you start another. Also, you need to use:
so we can read your mess
-
January 19th, 2010, 10:38 AM
#11
Re: Run-time error '91': Object variable or With block variable not set
same problem ..
For I = 1 To flow.Count - 1 '->error "block variable not set"
-
January 19th, 2010, 11:14 AM
#12
Re: Run-time error '91': Object variable or With block variable not set
pok3r824 Start a New thread please, as I'm closing this one
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|