Recordset problem

L

Luis

Hello.

I have a form with several fields and i'm using recordset clone property to
insert into an two dimension array variable( array_var(x,x) the name of the
field and the value of the field.

What i'm trying to do is to add a record on a table (Table1) with the values
stored on the array. All the information stored on the array is related only
to one record on the target table.

Can anyone give me a hint on looping through the array and store the info on
thos target table?

Thanks.

Luis
 
S

Stefan Hoffmann

hi Luis,
What i'm trying to do is to add a record on a table (Table1) with the values
stored on the array. All the information stored on the array is related only
to one record on the target table.
You normally don't need an array, try this:

Dim strSQL As String

strSQL = "INSERT INTO [yourTable] (fieldList) " & _
"VALUES (" & _
Me![field1] & ", " & _
Me![field2] & ", " & _
Me![fieldX] & ", " & _
")"

CurrentDb.Execute strSQL, dbFailOnError


When field is a String then you need

"'" & Replace(Me![fieldS], "'", "''") & "', " & _


mfG
--> stefan <--
 
L

Luis

The problem of that solution is that the form has about 50 fields.

There's going to be a huge INSERT statement.

Stefan Hoffmann said:
hi Luis,
What i'm trying to do is to add a record on a table (Table1) with the values
stored on the array. All the information stored on the array is related only
to one record on the target table.
You normally don't need an array, try this:

Dim strSQL As String

strSQL = "INSERT INTO [yourTable] (fieldList) " & _
"VALUES (" & _
Me![field1] & ", " & _
Me![field2] & ", " & _
Me![fieldX] & ", " & _
")"

CurrentDb.Execute strSQL, dbFailOnError


When field is a String then you need

"'" & Replace(Me![fieldS], "'", "''") & "', " & _


mfG
--> stefan <--
 

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

Similar Threads

Insert Statement 2
Copy ADO Recordset 2
Copy or addnew from an array 1
Fields in recordset 2
Create a tmp table from recordset 9
Moving a recordset into an array 1
Recordset code problem 5
Rebuilding Treeview 1

Top