Hello Group:
My first post on the group.Hope I get a response.
I have a modest Fire Insurance ACCES Db.Thanks to this group - for the
code. A "wanna be programmer"... "LEARNS"
The code here-under (from the Archive) duplicates the EXPIRING records
but affords the USER to give ONLY A NEW POLICY NO (NewKey),should a
client opt to renew upon expiry of the YEARLY POLICY.The NEW POLICY NO
is save as a NEW record along with the "old"static rec.
MY Need:
Could somebody help me "re-syntax"the code to accept the ff: flds via
"User Input" [NEWDATE_ISSUED], [NEWFROM_DATE],[NEWTO
_DATE],[NEW_flds],etc.
The system MUST RETAIN THE OLD RECORD.
I know DUPLICATION is a "boo-boo" in DB.
I'm working on it and I'll get there somehow.
Been working on this for days, smoke too many cig.!!
I need the code that works NOT "I'm stupid", I know that already"
ALL THE BEST!
josephm
'***************** Code Start *******************
'//This code from Jim Davis,University of Washington
NewKey = InputBox("Enter the new Policy No")
Dim DB as Database
Dim NewRS as Recordset, OldRS as Recordset
Dim SQL as String
'** Open recordsets.
SQL = "SELECT * FROM tablename WHERE (tablename.keyname ='"
SQL = SQL & txtKeyFieldOnForm & "');"
Set DB = DBEngine(0)(0)
Set OldRS = DB.OpenRecordset(SQL, DB_OPEN_DYNASET)
Set NewRS = DB.OpenRecordset("tablename", DB_OPEN_DYNASET)
'** Copy record
NewRS. AddNew
NewRS! KeyFieldName = NewKey
'** Copy remaining fields
For i = 1 to NewRS.Fields.Count - 1
NewRS(i) = OldRS(i)
Next i
NewRS.Update
NewRS.Close
OldRS.Close
'** Move form to new record
DoCmd ApplyFilter , "keyfieldnameintable ='" & NewKey & "'"
'***************** Code End **********************