Private Sub cmdSave_Click()
Dim rs As New ADODB.Recordset
If dbConn.State = adStateClosed Then dbConn.Open strConn
If lblEditID.Caption <> "" Then
rs.Open "select idClient,client_name,Address,City,state,country from tblClients where idClient=" & _
lblEditID, dbConn, adOpenStatic, adLockOptimistic
rs(1) = Trim(txtClient.Text)
rs(2) = Trim(txtAddress.Text)
rs(3) = Trim(txtCity.Text)
rs(4) = Trim(txtState.Text)
rs(5) = cmbCountry.SelText
rs.Update
rs.Close
Else
rs.Open "select idClient,client_name,Address,City,state,country from tblClients", dbConn, adOpenStatic, adLockOptimistic
rs.AddNew
rs(1) = Trim(txtClient.Text)
rs(2) = Trim(txtAddress.Text)
rs(3) = Trim(txtCity.Text)
rs(4) = Trim(txtState.Text)
rs(5) = cmbCountry.ListIndex = 0
rs.Update
rs.Close
End If
dbConn.Close
lblEditID.Caption = ""
UserForm_Activate
cmdClear_Click
End Sub
Dim rs As New ADODB.Recordset
If dbConn.State = adStateClosed Then dbConn.Open strConn
If lblEditID.Caption <> "" Then
rs.Open "select idClient,client_name,Address,City,state,country from tblClients where idClient=" & _
lblEditID, dbConn, adOpenStatic, adLockOptimistic
rs(1) = Trim(txtClient.Text)
rs(2) = Trim(txtAddress.Text)
rs(3) = Trim(txtCity.Text)
rs(4) = Trim(txtState.Text)
rs(5) = cmbCountry.SelText
rs.Update
rs.Close
Else
rs.Open "select idClient,client_name,Address,City,state,country from tblClients", dbConn, adOpenStatic, adLockOptimistic
rs.AddNew
rs(1) = Trim(txtClient.Text)
rs(2) = Trim(txtAddress.Text)
rs(3) = Trim(txtCity.Text)
rs(4) = Trim(txtState.Text)
rs(5) = cmbCountry.ListIndex = 0
rs.Update
rs.Close
End If
dbConn.Close
lblEditID.Caption = ""
UserForm_Activate
cmdClear_Click
End Sub