Cannot save form field values using an Append Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This works on Access by using an Append Query and Setting the columns to
Forms!frmForm1.Field1 for example. Now I am using SQL and Acess is an adp
file, I cannot do this any more. How do I do this please?

Thanks
Ian
 
Hi Jeff - thanks for the reply.

I created the following code:

----

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

It reports an error on the dbsMasterplan.Execute (MasterplanSQL) line,
Object variable or With block variable not set (Error 91)

Any ideas? I've created a refenece to DAO 3.6 Library

Thanks
Ian
 
I believe that when you are using an ADP, you use CurrentProject, not
CurrentDb.

You could also condsense all this into one statement by
DoCmd.RunSQL "Your SQL Statement". You wouldn't need your variables at
all if you use that method. Just a thought.
 
Thank You very much Jeff. The single statement did the trick. I knew it had
to be something simple to achieve a basic requirement. Do you know of any
good reference books on adp?

Ian
 
Back
Top