467,077 Members | 981 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

duplicate record command button

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
  • viewed: 2122
Share:
3 Replies
nico5038
Expert 2GB
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
thanks Nico, i'll have a look at that
Aug 13 '08 #3
nico5038
Expert 2GB
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.

Similar topics

9 posts views Thread by Catherine Jo Morgan | last post: by
8 posts views Thread by Ray | last post: by
1 post views Thread by 2D Rick | last post: by
9 posts views Thread by rjshrader@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.