Copy data to next record with button

Mike Auer

Registered User.
Local time
Today, 09:04
Joined
Apr 29, 2002
Messages
11
Hello.
I would like to have a button on my form that, when pressed, would copy all data that exists on the last record to a new record. However, there is a date field that I would like to update to the following day for that new record. And I would like the button to be visible or enabled only for the last record, including the newly created record. For example, all fields are filled for a new record. The magic button is pressed and a new record is created with all fields the same except the date field which is the following day. The magic button could again be pressed which will accomplish the same task. Is this possible? Any help would be greatly appreciated by me and the end user.
Thank you,
Mike.
 
Mike,

Code:
Dim dbs As Database
Dim rst As Recordset
Dim sql As String

Set dbs = CurrentDb
sql = "Select * from MyTable"
Set rst = dbs.OpenRecordset(sql)
sql = "Insert Into MyTable (F1, F2, FDate) " & _
      "Values ('" & Me.Field1 & "', '" & _
      "             Me.Field2 & "', #" & _
                    DateAdd("d", Me.ThatDate, 1) & "#);"
dbs.Execute(sql)

I don't have Access so I'm not sure about the syntax
of the DateAdd, but that's why they make Help files.

Wayne
 
Thanks, Wayne. I'll try it tomorrow and let you know.
Mike
 

Users who are viewing this thread

Back
Top Bottom