Private Sub cmdenter_Click()
If Option1.Value = True Then
db.Execute "Insert into TM_REGISTRATION values('" + txtregdn.Text + "','" + txtformno.Text + "','" + Combo1.Text + "','" + Format(mskadmdt.Text, "mm-dd-yyyy") + "','" + studentname.Text + "','" + Combo2.Text + "','" + fname.Text + "','" + fmobile.Text + "','" + mname.Text + "','" + mmobile.Text + "','" + gname.Text + "','" + gmobile.Text + "','" + Format(mskdob.Text, "mm-dd-yyyy") + "',1,0,'" + Combo3.Text + "','" + Combo4.Text + "','" + Combo5.Text + "','" + Combo6.Text + "','" + txtaddress1.Text + "','" + txtaddress2.Text + "','" + district.Text + "','" + pincode.Text + "','" + Picture1.Picture + "')"
ElseIf Option2.Value = True Then
db.Execute "Insert into TM_REGISTRATION values('" + txtregdn.Text + "','" + txtformno.Text + "','" + Combo1.Text + "','" + Format(mskadmdt.Text, "mm-dd-yyyy") + "','" + studentname.Text + "','" + Combo2.Text + "','" + fname.Text + "','" + fmobile.Text + "','" + mname.Text + "','" + mmobile.Text + "','" + gname.Text + "','" + gmobile.Text + "','" + Format(mskdob.Text, "mm-dd-yyyy") + "',0,1,'" + Combo3.Text + "','" + Combo4.Text + "','" + Combo5.Text + "','" + Combo6.Text + "','" + txtaddress1.Text + "','" + txtaddress2.Text + "','" + district.Text + "','" + pincode.Text + "','" + Picture1.Picture + "')"
End If
End Sub
Asked
Active
Viewed 50 times
-2

Yaseen Ahmad
- 1,807
- 5
- 25
- 43

Isaac Renthlei
- 11
- 3
-
[How to debug dynamic SQL in VBA](http://stackoverflow.com/a/1099570/3820271) – Andre May 02 '17 at 07:19
-
1What is the exact error message you receive? Is it from VB6 or is it from Access? – StayOnTarget May 02 '17 at 11:31
2 Answers
0
Format the date value expressions correctly:
db.Execute "Insert into TM_REGISTRATION values('" + txtregdn.Text + "','" + txtformno.Text + "','" + Combo1.Text + "',#" + Format(mskadmdt.Text, "yyyy\/mm\/dd") + "#,'" + studentname.Text + "','" + Combo2.Text + "','" + fname.Text + "','" + fmobile.Text + "','" + mname.Text + "','" + mmobile.Text + "','" + gname.Text + "','" + gmobile.Text + "',#" + Format(mskdob.Text, "yyyy\/mm\/dd") + "#,1,0,'" + Combo3.Text + "','" + Combo4.Text + "','" + Combo5.Text + "','" + Combo6.Text + "','" + txtaddress1.Text + "','" + txtaddress2.Text + "','" + district.Text + "','" + pincode.Text + "','" + Picture1.Picture + "')"

Gustav
- 53,498
- 7
- 29
- 55