Private Sub cmdAdd_Click()
Dim con As ADODB.Connection
Set con = New ADODB.Connection
Dim rsAdd As ADODB.Recordset
Set rsAdd = New ADODB.Recordset
Dim Query As String
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Asus\Desktop\VBTHESIS_liel2\ListofMembers.mdb;Persist Security Info=False"
con.CursorLocation = adUseClient
rsAdd.Open "SELECT * FROM census WHERE ID ='" & strId & "'", con, adOpenStatic, adLockOptimistic
'If textboxes are null then
MsgBox "Please fill in the required details. ", vbExclamation, "Santo Niño Census Info System"
txtEnterID.SetFocus
Exit Sub
'End If
'If record exists Then
MsgBox "Record has already exists!", vbExclamation, "Santo Niño Census Info System"
txtEnterID.Text = ""
txtLastName.Text = ""
txtFirstName.Text = ""
txtMiddleName.Text = ""
txtAge.Text = ""
txtSex.Text = ""
txtStatus.Text = ""
txtAddress.Text = ""
txtBirthDate.Text = ""
txtBirthPlace.Text = ""
txtCitizenship.Text = ""
txtReligion.Text = ""
txtOccupation.Text = ""
txtEnterID.SetFocus
Else
Query = "INSERT INTO census VALUES ('" & txtEnterID.Text & "', '" & txtLastName.Text & "', '" & txtFirstName.Text & "', '" & txtMiddleName.Text & "', '" & txtAge.Text & "', '" & txtSex.Text & "', '" & txtStatus.Text & "', '" & txtAddress.Text & "', '" & txtBirthDate.Text & "', '" & txtBirthPlace.Text & "', '" & txtCitizenship.Text & "', '" & txtReligion.Text & "', '" & txtOccupation.Text & "', '" & txtSkills.Text & "', '" & txtContactNo.Text & "') "
con.Execute Query, , adCmdText
MsgBox "Record successfuly added!", vbOKOnly, "Santo Niño Census Info System"
txtEnterID.Text = ""
txtLastName.Text = ""
txtFirstName.Text = ""
txtMiddleName.Text = ""
txtAge.Text = ""
txtSex.Text = ""
txtStatus.Text = ""
txtAddress.Text = ""
txtBirthDate.Text = ""
txtBirthPlace.Text = ""
txtCitizenship.Text = ""
txtReligion.Text = ""
txtOccupation.Text = ""
txtSkills.Text = ""
txtContactNo.Text = ""
txtEnterID.SetFocus
End If
End Sub
hi! please help me with this...