basically this is the code i was using before Kenneth's suggestion
Private Sub cmdOK_Click() If cbohandler.Value = "" Or txtClaim.Value = "" Or txtrecs.Value = "" Or cboCHO.Value = "" Or lstissue.Value = "" Or txtcommentry.Value = "" Then MsgBox "Please enter all fields before continuing!", vbCritical Exit Sub Else If txtcommentry.Value = "" Then txtcommentry.Value = "N/A" If txtrecs.Value = "" Then txtreason.Value = "N/A" ' exports data from the active form to a table in an Access database Dim cn As ADODB.Connection Dim rs As ADODB.Recordset ' connect to the Access database Set cn = New ADODB.Connection cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & "Data Source=cho.mdb;" ' open a recordset Set rs = New ADODB.Recordset rs.Open "SELECT * FROM [chotable]", cn, adOpenDynamic, adLockOptimistic With rs .AddNew .Fields("Handler Name") = cbohandler.Value .Fields("Claim Number") = txtClaim.Value .Fields("CHO") = cboCHO.Value .Fields("Issue(s)") = lstissue.Value .Fields("Commentry") = txtcommentry.Value .Fields("Recommendations") = txtrecs.Value .Update ' stores the new record End With rs.Close Set rs = Nothing cn.Close Set cn = Nothing End If Unload Me MsgBox "Entry Added Successfully", vbOKOnly End Sub




Reply With Quote