Hi Everyone
I started learning MS Access recently and started building a form to insert data into the database.I have a table tblPeople with columns peopleID,FirstName,LastName,Gender,Email,Phone. and the forms with the textboxes txtFirstName,txtLastName,txtGender,txtEmail,txtPho ne .I have return the code but am not knowing it is neither giving me any error message or inserting the data...below is the code I have return..Any help for me is very well appreciated...
Private Sub btnRegister_Click()
On Error GoTo Err_btnRegister_Click
Dim cn As ADODB.Connection, rs As ADODB.Recordset
Dim db As database
Dim cmd As ADODB.Command
Dim StringSql As String
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;", "Data Source=C:\MyFolder\Registration.mdb"
Set db = OpenDatabase("C:\MyFolder\Registration.mdb")
Set StringSql = "INSERT INTO tblPeople (FirstName, LastName, Gender, Email, Phone ) VALUES ('" & Me!txtFirstName.Value & "', '" & Me!txtLastName.Value & "', '" & Me!txtGender.Value & "', '" & Me!txtEmail.Value & "', '" & Me!txtPhoneNumber.Value & "');"
cmd.RunSQL StringSql
Set db = Nothing
Set StringSql = Nothing
Exit_btnRegister_Click:
Exit Sub
Err_btnRegister_Click:
MsgBox Err.Description
Resume Exit_btnRegister_Click
End Sub