|
-
September 19th, 1999, 08:43 PM
#1
Duplicating a Record
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
[email protected]
-
September 19th, 1999, 11:03 PM
#2
Re: Duplicating a Record
Hi,
There are some points before you duplicate the last record. If you are having index (unique) then table will always generate the error. So please ensure tha your table is not bound to 'unique' value field.
Most probably you want to set your table behaviour as age old dbase "set Carry on"
Ok. There is no problems in this, What I see in your code, you are missing a ")"
2. If only three fields are to be inserted then use simply INSERT INTO tableName (... ... ...) Values(... ... ..) thats all.
I hope you get it.
santulan
Santulan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|