E
elliottpt via AccessMonster.com
Hi
I'm struglling to figure this one out and some help would be much appreciated.
I have a data capturing form that has some VBA code attached to it that
creates a unique key based on information entered. I need to have the option
of duplicating a specific record which can be edited after duplication. I
currently have a control button(setup using the wizard) for the duplication.
When it is clicked upon the following error is displayed:
Run-time error '3020'
Update or CancelUpdate without Addnew or Edit
Below is my code with the problem seeming to be at the section with the stars
(***):
Private Sub TotalPallets_AfterUpdate()
'Create variables to hold VesselNo,Supplier code,POD and POL
' and Key
Dim vVesselNo As String
Dim sSuppCode As String
Dim pPOD As String
Dim pPOL As String
Dim kKey As String
Dim cComm As String
Dim pPlt As Integer
'Assign the text in the Supplier code text box to
' the sSuppCode variable.
Forms!Vesselcapturing!TotalPallets.SetFocus
pPlt = Forms!Vesselcapturing!TotalPallets.Text
'You must set the focus to a text box before
' you can read its contents.
Forms!Vesselcapturing!VesselNo.SetFocus
vVesselNo = Forms!Vesselcapturing!VesselNo.Text
Forms!Vesselcapturing!POL.SetFocus
pPOL = Forms!Vesselcapturing!POL.Text
Forms!Vesselcapturing!POD.SetFocus
pPOD = Forms!Vesselcapturing!POD.Text
Forms!Vesselcapturing!Comm.SetFocus
cComm = Forms!Vesselcapturing!Comm.Text
Forms!Vesselcapturing!Clientcodes.SetFocus
sSuppCode = Forms!Vesselcapturing!Clientcodes.Text
'Combine portions of the last and first names
' to create the Key.
kKey = vVesselNo & Left(sSuppCode, 5) & Left(cComm, 2) & pPlt & Left(pPOL,
3) & Left(pPOD, 3)
'Don't store the Key unless it is less than 22 characters long.
' (This would indicate all fields not filled it.)
If Len(kKey) <= 22 Then
Forms!Vesselcapturing!KEY.SetFocus
*** Forms!Vesselcapturing!KEY = kKey
End If
'Set the focus where it would have gone naturally.
Forms!Vesselcapturing!SailDate.SetFocus
End Sub
Help would be much appreciated!!!!!!
Regards
Philip
I'm struglling to figure this one out and some help would be much appreciated.
I have a data capturing form that has some VBA code attached to it that
creates a unique key based on information entered. I need to have the option
of duplicating a specific record which can be edited after duplication. I
currently have a control button(setup using the wizard) for the duplication.
When it is clicked upon the following error is displayed:
Run-time error '3020'
Update or CancelUpdate without Addnew or Edit
Below is my code with the problem seeming to be at the section with the stars
(***):
Private Sub TotalPallets_AfterUpdate()
'Create variables to hold VesselNo,Supplier code,POD and POL
' and Key
Dim vVesselNo As String
Dim sSuppCode As String
Dim pPOD As String
Dim pPOL As String
Dim kKey As String
Dim cComm As String
Dim pPlt As Integer
'Assign the text in the Supplier code text box to
' the sSuppCode variable.
Forms!Vesselcapturing!TotalPallets.SetFocus
pPlt = Forms!Vesselcapturing!TotalPallets.Text
'You must set the focus to a text box before
' you can read its contents.
Forms!Vesselcapturing!VesselNo.SetFocus
vVesselNo = Forms!Vesselcapturing!VesselNo.Text
Forms!Vesselcapturing!POL.SetFocus
pPOL = Forms!Vesselcapturing!POL.Text
Forms!Vesselcapturing!POD.SetFocus
pPOD = Forms!Vesselcapturing!POD.Text
Forms!Vesselcapturing!Comm.SetFocus
cComm = Forms!Vesselcapturing!Comm.Text
Forms!Vesselcapturing!Clientcodes.SetFocus
sSuppCode = Forms!Vesselcapturing!Clientcodes.Text
'Combine portions of the last and first names
' to create the Key.
kKey = vVesselNo & Left(sSuppCode, 5) & Left(cComm, 2) & pPlt & Left(pPOL,
3) & Left(pPOD, 3)
'Don't store the Key unless it is less than 22 characters long.
' (This would indicate all fields not filled it.)
If Len(kKey) <= 22 Then
Forms!Vesselcapturing!KEY.SetFocus
*** Forms!Vesselcapturing!KEY = kKey
End If
'Set the focus where it would have gone naturally.
Forms!Vesselcapturing!SailDate.SetFocus
End Sub
Help would be much appreciated!!!!!!
Regards
Philip