Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplicate record but exlude 1 field

Status
Not open for further replies.

capdownlondon

Technical User
Mar 4, 2007
9
GB
Ive made a button on my form to duplicate a record.
But i only want it to duplicate certain fields and leave the other fields blank (another form will deal with those values).
Is it possible to do this?

and also is it possible to do this but also having the duplicate record have, say, 1 week, added to the date field on the record aswell.

so in effect copying the selcted data and adding a week to it.
 
basically i would like to maybe hit a button that will run code that says duplicate record for x, y , z fields and duplicate w field + 1 week
 
actually w doesn't even need to add a week, because its an index number that realtes to a week.

so basically i need to know if i can code a button that will say. duplicate x y z and w+1.
 
How are ya capdownlondon . . .

In the [blue]Tag[/blue] property of the fields you wish to duplicate (new record), add a question mark [purple]?[/purple] Then in the [blue]On DBL Click[/blue] event of the form, copy/paste the following ([blue]you![/blue] substitute proper names in [purple]purple[/purple]):
Code:
[blue]   Dim rst As DAO.Recordset, ctl As Control
   
   Set rst = Me.RecordsetClone
   rst.Bookmark = Me.Bookmark
   Me.Recordset.AddNew
   
   For Each ctl In Me.Controls
      If ctl.Tag = "?" Then
         If Trim(rst(ctl.Name) & "") <> "" Then
            If ctl.Name = "[purple][b][i]DateFieldName[/i][/b][/purple]" Then
               Me(ctl.Name) = rst(ctl.Name) + 7
            Else
               Me(ctl.Name) = rst(ctl.Name)
            End If
         End If
      End If
   Next
   
   Set rst = Nothing
   
End Sub[/blue]
To make duplicates just double-click the [blue]Record Selector[/blue] of the desired record.

[blue]Your thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top