0

I have created a function in VBA to connect to a web service and retrieve an XML file. I then wanted to parse the XML and import the captured nodes into the SQL database.

I have managed to connect to the web service and parse the XML file and even show the values in a messagebox, but when i try and store the parameter via a SQL query, it asks me for a parameter value?

Example:

Set BodyStyle = domResponse.SelectSingleNode("/GetVehicles/DataArea/Vehicles/Vehicle/BodyStyle")


MsgBox (BodyStyle.Text)

DoCmd.RunSQL "INSERT INTO vHPI (BodyStyle) BodyStyle.Text"

The messagebox pops up with a value of MOTORCYCLE, but then i get a prompt asking me for a parameter for BodyStyle.Text

I dont understand how the system can show the parameter in a messagebox but say the parameter is empty when i want to insert it into the database?

Please help! Thanks Adam.

2 Answers 2

2

You can simply do this:

DoCmd.RunSQL "INSERT INTO vHPI (BodyStyle) VALUES ('" & BodyStyle.Text & "')"

Assuming your column is named BodyStyle and the table is vHPI

Sign up to request clarification or add additional context in comments.

Comments

0

Right now you have the literal value of "BodyStyle.Text" on your SQL statement. Try it like this...

DoCmd.RunSQL "INSERT INTO vHPI (BodyStyle) " + BodyStyle.Text

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.