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