G
Guest
Hello everyone,
Can someone please help me with this problem..
I am trying to duplicate values with a unique number (N_NUMBER) using a
duplicate command button in a form(the code for this is given at the end of
this post). I was able to do simple duplication of values that are entered in
the form into the table. However my manager wants it in a different way. I am
not sure if I can describe it correctly, so I am giving an example of what I
should be able to do.
For example: I want to duplicate 3650 records. I should be able to duplicate
it for a certain date/month/year. Say since I have 3650 records and when I
select a year, then I should be able to insert 10(3650/365) records under
each date in that particular year. I did work on the generic logic on how to
do it, but I am not sure how to or if I can do it in VBA or my logic is
correct or not. The logic that I though of is given below:
------------------------------------------------------------------------------------------------
No_Entires => # of records to be generated
Entries_Per_Day = No_Entries / 365
for (j=0;j<365;j++)
{
for(I=0;I<Entries_Per_Day;I++)
{
Temp = (currentdate + j) ‘current date is today’s date
Print Temp
}
}
-----------------------------------------------------------------------------------
The code that I used for duplication of records is given below:
------------------------------------------------------------------------------------------------
Private Sub Insert_Duplicates_Click()
On Error GoTo Err_Insert_Duplicates_Click
Dim COUNTER As Integer
For COUNTER = 0 To 5
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdPaste
Me!N_NUMBER_txt = Me.[N_NUMBER_txt] + 1
Next
Exit_Insert_Duplicates_Click:
Exit Sub
Err_Insert_Duplicates_Click:
MsgBox Err.Description
Resume Exit_Insert_Duplicates_Click
End Sub
Can someone please help me with this problem..
I am trying to duplicate values with a unique number (N_NUMBER) using a
duplicate command button in a form(the code for this is given at the end of
this post). I was able to do simple duplication of values that are entered in
the form into the table. However my manager wants it in a different way. I am
not sure if I can describe it correctly, so I am giving an example of what I
should be able to do.
For example: I want to duplicate 3650 records. I should be able to duplicate
it for a certain date/month/year. Say since I have 3650 records and when I
select a year, then I should be able to insert 10(3650/365) records under
each date in that particular year. I did work on the generic logic on how to
do it, but I am not sure how to or if I can do it in VBA or my logic is
correct or not. The logic that I though of is given below:
------------------------------------------------------------------------------------------------
No_Entires => # of records to be generated
Entries_Per_Day = No_Entries / 365
for (j=0;j<365;j++)
{
for(I=0;I<Entries_Per_Day;I++)
{
Temp = (currentdate + j) ‘current date is today’s date
Print Temp
}
}
-----------------------------------------------------------------------------------
The code that I used for duplication of records is given below:
------------------------------------------------------------------------------------------------
Private Sub Insert_Duplicates_Click()
On Error GoTo Err_Insert_Duplicates_Click
Dim COUNTER As Integer
For COUNTER = 0 To 5
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdPaste
Me!N_NUMBER_txt = Me.[N_NUMBER_txt] + 1
Next
Exit_Insert_Duplicates_Click:
Exit Sub
Err_Insert_Duplicates_Click:
MsgBox Err.Description
Resume Exit_Insert_Duplicates_Click
End Sub