Everything in your code looks okay at a glance. Is it possible a new record is being added somehow by cmdReset?
Rob
"Olu Solaru" <OluSolaru[ at ]discussions.microsoft.com> wrote in message news:2C4EECA2-2194-4999-B5C4-BD0685C57BE2[ at ]microsoft.com...
[Quoted Text] >I have figured out my own problem. i changed the following line - > Err_cmbSubmit_Click to Err_cmdSubmit_Click. > > But now I have another problem. It does not populate all the fields in the > table , meaning one field value is blank in the new record, and places the > missing field value in the next row. How can I get around this? > > "Olu Solaru" wrote: > >> I have a form that has the following command buttons, submit, retry, >> close, >> and combo boxes. >> >> After selecting my options from the combo box, and hit the submit button, >> I >> get the following error message: Compile Error - Label not defined. >> >> I have looked at my coding and can't seem to find anything wrong. >> >> Here is my code: >> Private Sub cmdSubmit_Click() >> On Error GoTo Err_cmdsubmit_Click >> Dim rstOrder As ADODB.Recordset >> Set rstOrder = New ADODB.Recordset >> >> rstOrder.Open "tblBprNumber", CurrentProject.Connection, >> adOpenStatic, >> adLockOptimistic >> If rstOrder.Supports(adAddNew) Then >> With rstOrder >> .AddNew >> .Fields("BprNumber") = txtBPRNumber >> .Fields("LotNumber") = txtLotNumber >> .Fields("Sop1") = cboSop1 >> .Fields("Sop2") = cboSop2 >> .Fields("Sop3") = cboSop3 >> .Fields("Sop4") = cboSop4 >> .Fields("Sop5") = cboSop5 >> .Fields("Sop6") = cboSop6 >> .Fields("Sop7") = cboSop7 >> .Fields("Sop8") = cboSop8 >> .Fields("Sop9") = cboSop9 >> .Fields("Sop10") = cboSop10 >> .Fields("Sop11") = cboSop11 >> .Fields("Sop12") = cboSop12 >> .Fields("Sop13") = cboSop13 >> .Fields("Sop14") = cboSop14 >> .Fields("Sop15") = cboSop15 >> .Fields("Sop16") = cboSop16 >> .Update >> cmdReset_Click >> End With >> End If >> >> rstOrder.Close >> Set rstOrder = Nothing >> >> DoCmd.Close >> >> Exit_cmbSubmit_Click: >> Exit Sub >> >> Err_cmbSubmit_Click: >> MsgBox Err.Description >> Resume Exit_cmbSubmit_Click >> >> End Sub >> >>
|