Question : Write Confilcts on Unbound Form using DAO Recordset

I have a unbound form that is either used for new record entry or for review based on the class of user that is going into the form. The problem I am having is that if a user updates the record and then cycles forward or back the updates are being saved with not issues. If the user updates the record and presses the close button the record is saved. However if the user updates the record and the presses the submit button, the update is saved. But when the user presses the close form button I get a write conflict but nothing has changed since the button was pressed. I have included the on load code and submit code below. Any help you can give me would be appreciated.

Jeff
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
**** load code
' Turn the MouseWheel Off
Dim blRet As Boolean
blRet = MouseWheelOFF
AllowClose = False
' Move to correct form based on security level
If user.AccessID = 4 Or user.AccessID = 28 Then
    DoCmd.GoToRecord acDataForm, "f_credits", acNewRec
End If
If user.AccessID = 3 Or user.AccessID = 1 Then
    DoCmd.GoToRecord acDataForm, "f_credits", acFirst
End If

' Enable buttons, textboxes, and labels based on security level
If user.AccessID = 3 Or user.AccessID = 1 Then
    Me.RecordSource = "SELECT tbl_credits.recid, tbl_credits.entryby, tbl_credits.entrydt, tbl_credits.credit_type, tbl_credits.mdn, tbl_credits.account_number, tbl_credits.billing_system, tbl_credits.home_sid, tbl_credits.fraud_sids, tbl_credits.mtas_status, tbl_credits.h_to_r_auth, tbl_credits.calls_to, tbl_credits.detect_type, tbl_credits.detection_date, tbl_credits.worked_date, tbl_credits.esn_chg_date, tbl_credits.start_of_calls, tbl_credits.end_of_calls, tbl_credits.cycle_time, tbl_credits.action_taken, tbl_credits.action_taken_date, tbl_credits.credit_category, tbl_credits.credit_amount, tbl_credits.est_credit_amount, tbl_credits.credit_issued, tbl_credits.comments, tbl_credits.lead_approved_by, tbl_credits.lead_approved_date, tbl_credits.credit_issued_by, tbl_credits.credit_issued_date, tbl_credits.region, tbl_credits.include, tbl_credits.newrecord FROM tbl_credits WHERE (((tbl_credits.newrecord)=True));"
    Me.txtrecid.ControlSource = "recid"
    Me.txtenteredby.ControlSource = "entryby"
    Me.cbocredittype.ControlSource = "credit_type"
    Me.txtmdn.ControlSource = "mdn"
    Me.txtaccountnumber.ControlSource = "account_number"
    Me.cboBillingSystem.ControlSource = "billing_system"
    Me.txtHomeSID.ControlSource = "home_sid"
    Me.txtfraudsid.ControlSource = "fraud_sids"
    Me.txtmtasstatus.ControlSource = "mtas_status"
    Me.cbohtorauth.ControlSource = "h_to_r_auth"
    Me.txtcallsto.ControlSource = "calls_to"
    Me.cbodetectiontype.ControlSource = "detect_type"
    Me.txtdetectiondate.ControlSource = "detection_date"
    Me.cboregion.ControlSource = "region"
    Me.txtdateworkedbycoordinator.ControlSource = "worked_date"
    Me.txtesnchangedatesoc.ControlSource = "esn_chg_date"
    Me.txtstartofcalls.ControlSource = "start_of_calls"
    Me.txtendofcalls.ControlSource = "end_of_calls"
    Me.txtcycletime.ControlSource = "cycle_time"
    Me.cboactiontaken.ControlSource = "action_taken"
    Me.txtactiontakendate.ControlSource = "action_taken_date"
    Me.cbocreditcategory.ControlSource = "credit_category"
    Me.txtcreditamount.ControlSource = "credit_amount"
    Me.txtestcreditamountsoc.ControlSource = "est_credit_amount"
    Me.cbocreditinfraudplus.ControlSource = "credit_issued"
    Me.txtcomments.ControlSource = "comments"
        
    Me.btnSave.Visible = False
    Me.cmdleadapproved.Visible = True
    Me.cmdsupapproved.Visible = True
    Me.btnadapproved.Visible = True
    Me.btnreject.Visible = True
    Me.btnFirst.Visible = True
    Me.btnPrev.Visible = True
    Me.btnNext.Visible = True
    Me.btnLast.Visible = True
    Me.txtRecordNos.Visible = True
    Me.txtrecid.Visible = True
    Me.txtenteredby.Visible = True
End If
If user.AccessID = 4 Or user.AccessID = 28 Then
    Me.btnSave.Visible = True
End If

**** submit code
Dim RS As DAO.Recordset, qdf As DAO.QueryDef
Set qdf = CurrentDb.QueryDefs("q_credit")
With qdf
    .Parameters("[Forms]![f_credits].[txtrecid]") = ([Forms]![f_credits].[txtrecid])
    Set RS = .OpenRecordset(dbOpenDynaset)
End With
'Set RS = CurrentDb.OpenRecordset("SELECT tbl_credits.recid, tbl_credits.entryby, tbl_credits.entrydt, tbl_credits.credit_type, tbl_credits.mdn, tbl_credits.account_number, tbl_credits.billing_system, tbl_credits.home_sid, tbl_credits.fraud_sids, tbl_credits.mtas_status, tbl_credits.h_to_r_auth, tbl_credits.calls_to, tbl_credits.detect_type, tbl_credits.detection_date, tbl_credits.worked_date, tbl_credits.esn_chg_date, tbl_credits.start_of_calls, tbl_credits.end_of_calls, tbl_credits.cycle_time, tbl_credits.action_taken, tbl_credits.action_taken_date, tbl_credits.credit_category, tbl_credits.credit_amount, tbl_credits.est_credit_amount, tbl_credits.credit_issued, tbl_credits.comments, tbl_credits.lead_approved_by, tbl_credits.lead_approved_date, tbl_credits.credit_issued_by, tbl_credits.credit_issued_date, tbl_credits.ad_approved_by, tbl_credits.ad_approved_date, tbl_credits.newrecord FROM tbl_credits WHERE (((tbl_credits.recid)=[forms]![f_credits]![txtrecid]));")
If Me.cbocreditcategory.Value = "$0 - $499" Then
    RS.Edit
    RS!credit_type = Me.cbocredittype
    RS!mdn = Me.txtmdn
    RS!account_number = Me.txtaccountnumber
    RS!billing_system = Me.cboBillingSystem
    RS!Home_SID = Me.txtHomeSID
    RS!fraud_sids = Me.txtfraudsid
    RS!mtas_status = Me.txtmtasstatus
    RS!h_to_r_auth = Me.cbohtorauth
    RS!calls_to = Me.txtcallsto
    RS!detect_type = Me.cbodetectiontype
    RS!detection_date = Me.txtdetectiondate
    RS!region = Me.cboregion
    RS!worked_date = Me.txtdateworkedbycoordinator
    RS!esn_chg_date = Me.txtesnchangedatesoc
    RS!start_of_calls = Me.txtstartofcalls
    RS!end_of_calls = Me.txtendofcalls
    RS!Cycle_Time = Me.txtcycletime
    RS!action_taken = Me.cboactiontaken
    RS!action_taken_date = Me.txtactiontakendate
    RS!credit_category = Me.cbocreditcategory
    RS!credit_amount = Me.txtcreditamount
    RS!est_credit_amount = Me.txtestcreditamountsoc
    RS!credit_issued = Me.cbocreditinfraudplus
    RS!comments = Me.txtcomments
    RS!lead_approved_by = fOSUserName()
    RS!lead_approved_date = Now()
    RS!newrecord = False
    RS.Update
    ' msgbox credit complete
    MsgBox "Credit Complete", vbOKOnly, "Credit Complete"
Else
    RS.Edit
    RS!credit_type = Me.cbocredittype
    RS!mdn = Me.txtmdn
    RS!account_number = Me.txtaccountnumber
    RS!billing_system = Me.cboBillingSystem
    RS!Home_SID = Me.txtHomeSID
    RS!fraud_sids = Me.txtfraudsid
    RS!mtas_status = Me.txtmtasstatus
    RS!h_to_r_auth = Me.cbohtorauth
    RS!calls_to = Me.txtcallsto
    RS!detect_type = Me.cbodetectiontype
    RS!detection_date = Me.txtdetectiondate
    RS!region = Me.cboregion
    RS!worked_date = Me.txtdateworkedbycoordinator
    RS!esn_chg_date = Me.txtesnchangedatesoc
    RS!start_of_calls = Me.txtstartofcalls
    RS!end_of_calls = Me.txtendofcalls
    RS!Cycle_Time = Me.txtcycletime
    RS!action_taken = Me.cboactiontaken
    RS!action_taken_date = Me.txtactiontakendate
    RS!credit_category = Me.cbocreditcategory
    RS!credit_amount = Me.txtcreditamount
    RS!est_credit_amount = Me.txtestcreditamountsoc
    RS!credit_issued = Me.cbocreditinfraudplus
    RS!comments = Me.txtcomments
    RS!lead_approved_by = fOSUserName()
    RS!lead_approved_date = Now()
    RS.Update
    
    
    'Call email function to sups
    Call lead_approved
End If
Set RS = Nothing
Set qdf = Nothing

Answer : Write Confilcts on Unbound Form using DAO Recordset

Are you using linked tables? If you are, then there's really no reason to not use Bound forms completely, and let Access handle the data layer portion of this - in other words, you don't need your Submit code with bound forms.

Random Solutions  
 
programming4us programming4us