By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,620 Members | 1,302 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,620 IT Pros & Developers. It's quick & easy.

duplicate record command button

P: 6
hi guys
i need help, i have a form which is diplayed in a Datasheet view with more that 2 hundred records, when a user needs to add new entries i want him/her to select atleast 5 or more rows and click duplicate record button to duplicate those five records but at the moment only 1 record is getting duplicated
Aug 12 '08 #1
Share this Question
Share on Google+
3 Replies


nico5038
Expert 2.5K+
P: 3,072
Hi nomvula,

Best to check the code of this sample:
http://www.geocities.com/nico5038/xS...p-Down2000.zip
It shows how to select the rows from a datasheet subform and will allow you to write the needed INSERT loop.

Nic;o)
Aug 12 '08 #2

P: 6
thanks Nico, i'll have a look at that
Aug 13 '08 #3

nico5038
Expert 2.5K+
P: 3,072
In the subform the code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2. Parent.txtSelLength = Me.SelHeight
  3. Parent.txtSelstart = Me.SelTop
  4.  
  5. Dim rs As Recordset
  6. Dim intI As Integer
  7.  
  8. Set rs = Me.RecordsetClone
  9.  
  10. rs.MoveFirst
  11. intI = 1
  12. While intI < Me.SelTop
  13.  intI = intI + 1
  14.  rs.MoveNext
  15. Wend
  16. 'now positioned on the first
  17.  
  18. 'Init resultfield
  19. Parent.txtSelected = ""
  20.  
  21. intI = 0
  22.  
  23. While intI < Me.SelHeight
  24.  Parent.txtSelected = Parent.txtSelected & " " & rs!Field1
  25.  intI = intI + 1
  26.  rs.MoveNext
  27. Wend
  28.  
  29. Set rs = Nothing
  30.  
  31. End Sub
  32.  
Is filling the fields of the mainform with the rows and more important the keys (here field1). The same loop can be used to execute an insert statement for duplicating the selected rows.

What more do you need o know ?

Nic;o)
Aug 25 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.