2017-05-02 10 views
-2
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 
+0

[VBA에서 동적 SQL을 디버깅하는 방법 (http://stackoverflow.com/a/1099570/3820271) – Andre

+1

정확한 오류 메시지는 무엇입니까? 그것은 VB6에서 또는 액세스에서입니까? – DaveInCaz

답변

0

형식 정확하게 날짜 값 식 :

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 + "')"