T
TL
I have been having problems getting a Copy to New Record button to work. I
have finally determined that the autofill function is interfering with the
Copy to New Record button. The Copy to New Record code is below:
Private Sub CopyRecord_Click()
On Error GoTo Err_CopyRecord_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
Exit_CopyRecord_Click:
Exit Sub
Err_CopyRecord_Click:
MsgBox Err.Description
Resume Exit_CopyRecord_Click
End Sub
The code for the AutoFillNewRecord Function is below:
Function AutoFillNewRecord(F As Form)
Dim RS As Recordset, C As Control
Dim FillFields As String, FillAllFields As Integer
On Error Resume Next
'Exit if not on the new record.
If Not F.NewRecord Then Exit Function
'Goto the last record of the form recordset (to autofill form)
Set RS = F.RecordsetClone
RS.MoveLast
'Exit if you cannot move to the last record(no records).
If Err <> 0 Then Exit Function
'Get the list of fields to autofill.
FillFields = ";" & F![AutoFillNewRecordFields] & ";"
'If there is no criteria field, then set flag indicating ALL
'fields should be autofilled.
FillAllFields = Err <> 0
F.Painting = False
'Visit each field on the form.
For Each C In F
'Fill the field if ALL fields are to be filled OR if the
'...ControlSource field cn be found inthe FillFields list.
If FillAllFields Or InStr(FillFields, ";" & (C.Name) & ";") > 0 Then
C = RS(C.ControlSource)
End If
Next
F.Painting = True
End Function
Is there anyway to end the AutoFillNewRecord Function from the Private Sub
CopyRecord? I am very new to Access and VBA and will appreciate any help
given.
Thanks,
Tiffany
have finally determined that the autofill function is interfering with the
Copy to New Record button. The Copy to New Record code is below:
Private Sub CopyRecord_Click()
On Error GoTo Err_CopyRecord_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
Exit_CopyRecord_Click:
Exit Sub
Err_CopyRecord_Click:
MsgBox Err.Description
Resume Exit_CopyRecord_Click
End Sub
The code for the AutoFillNewRecord Function is below:
Function AutoFillNewRecord(F As Form)
Dim RS As Recordset, C As Control
Dim FillFields As String, FillAllFields As Integer
On Error Resume Next
'Exit if not on the new record.
If Not F.NewRecord Then Exit Function
'Goto the last record of the form recordset (to autofill form)
Set RS = F.RecordsetClone
RS.MoveLast
'Exit if you cannot move to the last record(no records).
If Err <> 0 Then Exit Function
'Get the list of fields to autofill.
FillFields = ";" & F![AutoFillNewRecordFields] & ";"
'If there is no criteria field, then set flag indicating ALL
'fields should be autofilled.
FillAllFields = Err <> 0
F.Painting = False
'Visit each field on the form.
For Each C In F
'Fill the field if ALL fields are to be filled OR if the
'...ControlSource field cn be found inthe FillFields list.
If FillAllFields Or InStr(FillFields, ";" & (C.Name) & ";") > 0 Then
C = RS(C.ControlSource)
End If
Next
F.Painting = True
End Function
Is there anyway to end the AutoFillNewRecord Function from the Private Sub
CopyRecord? I am very new to Access and VBA and will appreciate any help
given.
Thanks,
Tiffany