Object variable or With block variable not set (Error 91)

I

Ian Bateman

I am getting this error message when I try to execute this code in my Access
Project (adp), any ideas on what is going wrong? I have ticked 'Microsoft
DAO 3.6 Object Library in References.

It is supposed to be appending and order details record to the table
OrderDetails

Many Thanks
Ian

----

Private Sub AddItem_Click()
Dim dbsMasterplan As Database
Set dbsMasterplan = CurrentDb

Dim MasterplanSQL As String

MasterplanSQL = "INSERT INTO OrderDetails
(OrderID,ProductID,ProductName,UnitPrice,Quantity,Colour) VALUES("

MasterplanSQL = MasterplanSQL & Forms!frm_Orders.OrderID & ", " & ProductID
& ", '" & Product & "', " & SetPrice & ", " & Quantity & ", '" & Description
& "')"

dbsMasterplan.Execute (MasterplanSQL)

End Sub
 
C

Cindy M.

Hi =?Utf-8?B?SWFuIEJhdGVtYW4=?=,

It would help if you indicated which line is causing the error. Right off hand,
I'd have to ask where the variables ProductID, Product, SetPrice, etc. are
supposed to be coming from...
I am getting this error message when I try to execute this code in my Access
Project (adp), any ideas on what is going wrong? I have ticked 'Microsoft
DAO 3.6 Object Library in References.

It is supposed to be appending and order details record to the table
OrderDetails

Many Thanks
Ian

----

Private Sub AddItem_Click()
Dim dbsMasterplan As Database
Set dbsMasterplan = CurrentDb

Dim MasterplanSQL As String

MasterplanSQL = "INSERT INTO OrderDetails
(OrderID,ProductID,ProductName,UnitPrice,Quantity,Colour) VALUES("

MasterplanSQL = MasterplanSQL & Forms!frm_Orders.OrderID & ", " & ProductID
& ", '" & Product & "', " & SetPrice & ", " & Quantity & ", '" & Description
& "')"

dbsMasterplan.Execute (MasterplanSQL)

End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
I

Ian Bateman

Hi Cindy,

When I go into Debug, the line shaded in yellow is:
dbsMasterplan.Execute (MasterplanSQL)

The fields are coming from the Access Form on which the click button running
this code is situated.

Thanks
Ian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top