Recordset problem

  • Thread starter Thread starter Luis
  • Start date Start date
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
 
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 <--
 
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 <--
 
Back
Top