Hello All,
Please help. Below is my code on click it produced the Error message Error 3367 Object already in collection. Cannot append.
Private Sub cmdSave_Click()
'Dim strNewBordNo As String
'Dim strMsg As String
On Error GoTo Save_Error
'Dim StrBordNo As String
'StrBordNo = Me.txtBordNo
' Moved this code from For_BeforeUpdate tp Save event as part of WP002
'ValidFail = False
'strMsg = ""
'InsertReissueStgData
'Dim ctl As Control
'For Each ctl In Me.Controls
' If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
' If ctl.Tag = "Mandatory" And Nz(ctl.Value, "") = "" Then
' strMsg = strMsg + ctl.Controls(0).Caption & vbTab & ctl.Tag & vbCrLf
' End If
' End If
'Next ctl
'Cheque Populated
'Dim strcheck As String
'strcheck = Nz(Me.cboPaymentMthd, "")
'If Nz(Me.cboPaymentMthd.Value, "") = "Cheq" And Nz(Me.cboPaymentMthd.Value, "") <> "" Then
' For Each ctl In Me.Controls
' If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
' If ctl.Tag = "ChequeMan" And Nz(ctl.Value, "") = "" Then
' strMsg = strMsg + ctl.Controls(0).Caption & vbTab & "Mandatory" & vbCrLf
' End If
' End If
' Next ctl
' Else
' For Each ctl In Me.Controls
' If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
' If ctl.Tag = "BacsMan" And Nz(ctl.Value, "") = "" Then
' strMsg = strMsg + ctl.Controls(0).Caption & vbTab & "Mandatory" & vbCrLf
' End If
' End If
' Next ctl
'End If
'If strMsg <> "" Then 'Cancels out of save if any Mandatory fields are empty
' MsgBox "Please populate below fields" & vbCrLf & vbCrLf & _
' strMsg, vbCritical, "Mandatory Fields"
' Dim Cancel As Boolean
' Cancel = True
' Exit Sub
'Else
'DoCmd.RunCommand acCmdSaveRecord
' Call Insert Data to Reissue Data
' InsertReissueStgData
'End If
Call InsertReissueStgData
cmdSave_Click_Exit:
DoCmd.Close acForm, Me.Name
Exit Sub
Save_Error:
If Err.Number <> 2501 And Err.Number <> 0 And Err.Number <> 30014 Then '30014 Added for WP002
modMessageHelper.ShowErrorMessage Err.Description, "frmInsertReissueRecord.cmdSave_Click", Err.Number
Else
DoCmd.Close acForm, Me.Name 'Added for WP002
End If
Exit Sub
'DoCmd.Close acForm, Me.Name
End Sub
Please help. Below is my code on click it produced the Error message Error 3367 Object already in collection. Cannot append.
Private Sub cmdSave_Click()
'Dim strNewBordNo As String
'Dim strMsg As String
On Error GoTo Save_Error
'Dim StrBordNo As String
'StrBordNo = Me.txtBordNo
' Moved this code from For_BeforeUpdate tp Save event as part of WP002
'ValidFail = False
'strMsg = ""
'InsertReissueStgData
'Dim ctl As Control
'For Each ctl In Me.Controls
' If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
' If ctl.Tag = "Mandatory" And Nz(ctl.Value, "") = "" Then
' strMsg = strMsg + ctl.Controls(0).Caption & vbTab & ctl.Tag & vbCrLf
' End If
' End If
'Next ctl
'Cheque Populated
'Dim strcheck As String
'strcheck = Nz(Me.cboPaymentMthd, "")
'If Nz(Me.cboPaymentMthd.Value, "") = "Cheq" And Nz(Me.cboPaymentMthd.Value, "") <> "" Then
' For Each ctl In Me.Controls
' If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
' If ctl.Tag = "ChequeMan" And Nz(ctl.Value, "") = "" Then
' strMsg = strMsg + ctl.Controls(0).Caption & vbTab & "Mandatory" & vbCrLf
' End If
' End If
' Next ctl
' Else
' For Each ctl In Me.Controls
' If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
' If ctl.Tag = "BacsMan" And Nz(ctl.Value, "") = "" Then
' strMsg = strMsg + ctl.Controls(0).Caption & vbTab & "Mandatory" & vbCrLf
' End If
' End If
' Next ctl
'End If
'If strMsg <> "" Then 'Cancels out of save if any Mandatory fields are empty
' MsgBox "Please populate below fields" & vbCrLf & vbCrLf & _
' strMsg, vbCritical, "Mandatory Fields"
' Dim Cancel As Boolean
' Cancel = True
' Exit Sub
'Else
'DoCmd.RunCommand acCmdSaveRecord
' Call Insert Data to Reissue Data
' InsertReissueStgData
'End If
Call InsertReissueStgData
cmdSave_Click_Exit:
DoCmd.Close acForm, Me.Name
Exit Sub
Save_Error:
If Err.Number <> 2501 And Err.Number <> 0 And Err.Number <> 30014 Then '30014 Added for WP002
modMessageHelper.ShowErrorMessage Err.Description, "frmInsertReissueRecord.cmdSave_Click", Err.Number
Else
DoCmd.Close acForm, Me.Name 'Added for WP002
End If
Exit Sub
'DoCmd.Close acForm, Me.Name
End Sub