Message Box to Display Records that have just been created

Symon

Registered User.
Local time
Today, 20:07
Joined
Aug 20, 2014
Messages
19
Hi All,

I have a button that duplicates records 'X' amount of times based on a value in a text box.

I need a message box to advise the user that they have created record number from - to

Eg

User creates 5 records - first record created has a auto number of 3200
I need the message box to say 'you have just created records 3200 - 3204

Is this possible?

Here is the current code on the duplicate button courtesy of Uncle Gizmo

Code:
Private Sub AddRecord_Click()
On Error GoTo AddRecord_Click_Err

Dim x As Integer
        For x = 1 To (Me.txtAmount.Value - 1)
    
    DoCmd.RunCommand acCmdSelectRecord
        DoCmd.RunCommand acCmdCopy
        DoCmd.RunCommand acCmdRecordsGoToNew
        DoCmd.RunCommand acCmdSelectRecord
        DoCmd.RunCommand acCmdPaste

Next x

AddRecord_Click_Exit:
    Exit Sub

AddRecord_Click_Err:
    MsgBox Error$
    Resume AddRecord_Click_Exit

End Sub

Thanks
 
Code:
   'this will get the last index created
vNumStart = dMax("[id]",table) + 1
vNumEnd = vNumStart + txtAmount.Value

   'append records ehre

msgbox "You just created records: " & vNumStart & "-" & vNumEnd
Hi All,

I have a button that duplicates records 'X' amount of times based on a value in a text box.

I need a message box to advise the user that they have created record number from - to

Eg

User creates 5 records - first record created has a auto number of 3200
I need the message box to say 'you have just created records 3200 - 3204

Is this possible?

Here is the current code on the duplicate button courtesy of Uncle Gizmo

Code:
Private Sub AddRecord_Click()
On Error GoTo AddRecord_Click_Err

Dim x As Integer
        For x = 1 To (Me.txtAmount.Value - 1)
    
    DoCmd.RunCommand acCmdSelectRecord
        DoCmd.RunCommand acCmdCopy
        DoCmd.RunCommand acCmdRecordsGoToNew
        DoCmd.RunCommand acCmdSelectRecord
        DoCmd.RunCommand acCmdPaste

Next x

AddRecord_Click_Exit:
    Exit Sub

AddRecord_Click_Err:
    MsgBox Error$
    Resume AddRecord_Click_Exit

End Sub

Thanks
 
Thanks Ranman

I went with the following in the end.

Thanks for taking the time to reply

Code:
Private Sub AddRecord_Click()
Dim lngRecordStart As Long
Dim lngRecordEnd As Long
Dim x As Integer

        'For x = 1 To (Me.Amount.Value - 1)
        For x = 1 To (Me.Amount.Value - 1)
    
    DoCmd.RunCommand acCmdSelectRecord
        DoCmd.RunCommand acCmdCopy
        DoCmd.RunCommand acCmdRecordsGoToNew
        DoCmd.RunCommand acCmdSelectRecord
        DoCmd.RunCommand acCmdPaste

If x = 1 Then
lngRecordStart = (Me![Serial Number] - 1)
lngRecordEnd = Me![Serial Number]
Else
lngRecordEnd = Me![Serial Number]
End If

Next x

MsgBox "Creation of serial numbers " & lngRecordStart & " - " & lngRecordEnd
End Sub
 

Users who are viewing this thread

Back
Top Bottom