murphyt
September 19th, 1999, 08:43 PM
Hi All,
I am using VB5 Pro with Access 97 Database.
I want to be able to Duplicate Part of the last record entered into the database.
I have got this far but need help,
Dim dbs As Database
Dim fldTemp As Field
Dim strSQL As String
Dim rstMyRecords As Recordset
Set dbs = OpenDatabase("c:\temp\duplicate\cars.mdb")
set rstMyRecords = Form1.dtacars.Recordset
rstMyRecords.MoveLast
strSQL = "INSERT INTO Cars Values _('Vehicle','Manufacturer','Model'"
For Each fldTemp in rstMyRecords
strSQL = strSQL & "" & fldTemp.Value & ","
Next fldTemp
strSQL = Left(strSQL,Len(strSQL)-2)
strSQL = strSQL & ")
dbs.Execute. strSQL
dbs.Close
It goes into error at For Each and I am stumped.
I only want to duplicate some of the text fields but there are numeric fields in the Recordset, so is this what is causing the problem.
Please advise if you can help.
Thanks
murphyt@icr.com.au
I am using VB5 Pro with Access 97 Database.
I want to be able to Duplicate Part of the last record entered into the database.
I have got this far but need help,
Dim dbs As Database
Dim fldTemp As Field
Dim strSQL As String
Dim rstMyRecords As Recordset
Set dbs = OpenDatabase("c:\temp\duplicate\cars.mdb")
set rstMyRecords = Form1.dtacars.Recordset
rstMyRecords.MoveLast
strSQL = "INSERT INTO Cars Values _('Vehicle','Manufacturer','Model'"
For Each fldTemp in rstMyRecords
strSQL = strSQL & "" & fldTemp.Value & ","
Next fldTemp
strSQL = Left(strSQL,Len(strSQL)-2)
strSQL = strSQL & ")
dbs.Execute. strSQL
dbs.Close
It goes into error at For Each and I am stumped.
I only want to duplicate some of the text fields but there are numeric fields in the Recordset, so is this what is causing the problem.
Please advise if you can help.
Thanks
murphyt@icr.com.au