G
Greg Maxey
I am very green at this stuff so if the answer should be obvious then
please be understanding ;-)
I am try to run the following bit of code in a Word macro. I am
getting an error on the line"
vConnection.Execute pSQL
The error states "No value given for one or more required parameters.
What am I missing? I have a simple database in Access with three
fields "Test1, Test2, and Test3." I am simply trying to write the
TestText1, 2, 3 to the fields. Ultimately I want to write Word field
code in the database fields, but I can't get passed this simple test.
Thanks.
Sub Testing()
'Requires reference to MS ActiveX Data Objects 2.8 Library
Dim vConnection As New ADODB.Connection
Dim vRecordSet As New ADODB.Recordset
Dim pSQL As String
Dim oTest As String
Application.ScreenUpdating = False
'Provide connection string for data using Jet Provider for Access
database
vConnection.ConnectionString = "data source=E:\My
Documents\Batch\TestDataBase2.mdb;" & _
"Provider=Microsoft.Jet.OLEDB.4.0;"
vConnection.Open
vRecordSet.Open "MyTable", vConnection, adOpenKeyset, adLockOptimistic
vConnection.Execute "DELETE * FROM MyTable"
pSQL = "INSERT INTO MyTable(Test1, Test2, Test3) VALUES(TestText1,
TestText2, TestText3)"
vConnection.Execute pSQL
vRecordSet.Update
vRecordSet.Close
vConnection.Close
Set vRecordSet = Nothing
Set vConnection = Nothing
Application.ScreenUpdating = True
End Sub
please be understanding ;-)
I am try to run the following bit of code in a Word macro. I am
getting an error on the line"
vConnection.Execute pSQL
The error states "No value given for one or more required parameters.
What am I missing? I have a simple database in Access with three
fields "Test1, Test2, and Test3." I am simply trying to write the
TestText1, 2, 3 to the fields. Ultimately I want to write Word field
code in the database fields, but I can't get passed this simple test.
Thanks.
Sub Testing()
'Requires reference to MS ActiveX Data Objects 2.8 Library
Dim vConnection As New ADODB.Connection
Dim vRecordSet As New ADODB.Recordset
Dim pSQL As String
Dim oTest As String
Application.ScreenUpdating = False
'Provide connection string for data using Jet Provider for Access
database
vConnection.ConnectionString = "data source=E:\My
Documents\Batch\TestDataBase2.mdb;" & _
"Provider=Microsoft.Jet.OLEDB.4.0;"
vConnection.Open
vRecordSet.Open "MyTable", vConnection, adOpenKeyset, adLockOptimistic
vConnection.Execute "DELETE * FROM MyTable"
pSQL = "INSERT INTO MyTable(Test1, Test2, Test3) VALUES(TestText1,
TestText2, TestText3)"
vConnection.Execute pSQL
vRecordSet.Update
vRecordSet.Close
vConnection.Close
Set vRecordSet = Nothing
Set vConnection = Nothing
Application.ScreenUpdating = True
End Sub