Ashfaque
Search Beautiful Girls from your town for night
- Local time
- Today, 21:25
- Joined
- Sep 6, 2004
- Messages
- 894
Hi,
I have write conflict issue on adding next record.
When I add new record from form it records successfully. When I try to add another record after saving first one, Run-time error 3022 displays.
But strange is when I close the form and reopen it for adding new record…it works. I tried refreshing, Requering but not usefull.
Below is my code for on ADD button on my form.
Dim X As String
X = DCount("*", "T_IssuedWarnings", "Criteria = '" & Forms!F_IssuedWarnings!Criteria & "' And Cno = " & Forms!F_IssuedWarnings!CNo) + 1
MsgBox ("Total Warnings") & " - " & X
Me.WCounter = X
If (IsNull(Me.FirstTime) And IsNull(Me.SecondTime)) And (IsNull(Me.ThirdTime) And IsNull(Me.FourthTime)) Then
MsgBox ("This is ") & X
MsgBox ("Please Enter Action"), vbCritical
Exit Sub
Else
If Not IsNull(WarningID) Then
‘’’’’’’’ BELOW IS MAIN CODE WHERE FACTING PROBLEM..ALTHOUGH IT IS SAVING FIRST REC BUT NOT SAVING SECOND REC IN CONTINUATION. I HAVE TO CLOSE FORM AND THEN REOPEN AND PERFORM ADDITION..
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim fld As DAO.Field
Set rst = CurrentDb.OpenRecordset("Select * from T_IssuedWarnings Where WarningID=" & Me.WarningID)
If rst.EOF And rst.BOF Then
rst.AddNew
For Each fld In rst.Fields
rst(fld.name) = Me(fld.name)
Next fld
rst.Update
rst.Close
Set rst = Nothing
If (Eval("MsgBox ('Record Saved Successfully.@ @',64,' Bold Texts')")) = vbOKOnly Then
End If
End If
Me.CmdSaveWarnLetter.Enabled = False
Else
If (Eval("MsgBox ('Nothing To Save.@ @',64,' Bold Texts')")) = vbOKOnly Then
Me.CmdSaveWarnLetter.Enabled = False
Exit Sub
End If
End If
Me.CmdUpdateWarnLett.Enabled = True
Me.CboSearchWarn.Requery
Me.Refresh
End If
I have write conflict issue on adding next record.
When I add new record from form it records successfully. When I try to add another record after saving first one, Run-time error 3022 displays.
But strange is when I close the form and reopen it for adding new record…it works. I tried refreshing, Requering but not usefull.
Below is my code for on ADD button on my form.
Dim X As String
X = DCount("*", "T_IssuedWarnings", "Criteria = '" & Forms!F_IssuedWarnings!Criteria & "' And Cno = " & Forms!F_IssuedWarnings!CNo) + 1
MsgBox ("Total Warnings") & " - " & X
Me.WCounter = X
If (IsNull(Me.FirstTime) And IsNull(Me.SecondTime)) And (IsNull(Me.ThirdTime) And IsNull(Me.FourthTime)) Then
MsgBox ("This is ") & X
MsgBox ("Please Enter Action"), vbCritical
Exit Sub
Else
If Not IsNull(WarningID) Then
‘’’’’’’’ BELOW IS MAIN CODE WHERE FACTING PROBLEM..ALTHOUGH IT IS SAVING FIRST REC BUT NOT SAVING SECOND REC IN CONTINUATION. I HAVE TO CLOSE FORM AND THEN REOPEN AND PERFORM ADDITION..
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim fld As DAO.Field
Set rst = CurrentDb.OpenRecordset("Select * from T_IssuedWarnings Where WarningID=" & Me.WarningID)
If rst.EOF And rst.BOF Then
rst.AddNew
For Each fld In rst.Fields
rst(fld.name) = Me(fld.name)
Next fld
rst.Update
rst.Close
Set rst = Nothing
If (Eval("MsgBox ('Record Saved Successfully.@ @',64,' Bold Texts')")) = vbOKOnly Then
End If
End If
Me.CmdSaveWarnLetter.Enabled = False
Else
If (Eval("MsgBox ('Nothing To Save.@ @',64,' Bold Texts')")) = vbOKOnly Then
Me.CmdSaveWarnLetter.Enabled = False
Exit Sub
End If
End If
Me.CmdUpdateWarnLett.Enabled = True
Me.CboSearchWarn.Requery
Me.Refresh
End If