本文介绍了通过vb保存新表和更新表中现有记录的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Private Sub SAVE_Click()
Dim SQL As String
''If Combo4.Text = 121 Then
SQL = "UPDATE STUDENT_RECORD_DATABASE "
SQL = SQL + " SET ROLLNO= " & Val(Combo4) & ","
SQL = SQL + "FIRST_NAME= ''" & Trim(Text2) & "'',"
SQL = SQL + "MIDDLE_NAME= ''" & Trim(Text3) & "'',"
SQL = SQL + "LAST_NAME= ''" & Trim(Text4) & "'',"
SQL = SQL + "CONTACT=" & Val(Text5) & ","
SQL = SQL + "CONTACT1=" & Val(Text6) & ","
SQL = SQL + "CONTACT2=" & Val(Text7) & ","
SQL = SQL + "ADDRESS= ''" & Trim(Text8) & "'',"
SQL = SQL + "GRADE=''" & Val(Combo1) & "'',"
THIS CODE WILL WORK?  SQL = SQL + "DIVID=''" & Val(Combo2) & "''"
OR THIS ONE-    ''SQL = SQL + "SELECT * FROM DIVISION WHERE DIV=''" & Combo2.Text & "'',"
SQL = SQL + "BLOOD_GROUP=''" & Val(Combo3) & "'',"
THIS CODE WILL WORK?  SQL = SQL + "HID=''" & Val(Combo9) & "'',"
OR THIS ONE-    ''SQL = SQL + "SELECT * FROM HNM WHERE HOUSE=''" & Val(Combo9) & "'',"
SQL = SQL + "TRANSPORT=''" & Val(Combo10) & "'',"
SQL = SQL + "SNAME=''" & Val(Combo5) & "'',"
SQL = SQL + "MEAL=''" & Val(Combo11) & "'',"
SQL = SQL + "BUSNO=''" & Val(Combo6) & "'',"
SQL = SQL + "RUTNO=" & Val(Combo12) & ","
THIS CODE WILL WORK?  SQL = SQL + "DID=''" & Val(Combo7) & "''"
OR THIS ONE-    ''SQL = SQL + "SELECT *FROM DRIVER WHERE DNAME=''" & Val(Combo7) & "'',"
THIS WILL WORK?  SQL = SQL + "AID=''" & Val(Combo8) & "''"
OR THIS WILL-   ''SQL = SQL + "SELECT * FROM ATTEND WHERE ANM=''" & Val(Combo8) & "'',"
SQL = SQL + "CARD_TYPE=''" & Val(Combo13) & "'',"
SQL = SQL + "CARD_NO=" & Val(Text11) & ""
SQL = SQL + "WHERE ROLLNO= " & Val(Combo4) & ""
CON.Execute (SQL)
''RES.Update
    MsgBox ("RECORD UPDATED")

ELSE
SQL = "INSERT INTO STUDENT_RECORD_DATABASE WHERE ROLLNO=" & Combo4.Text
   SQL = SQL + "VALUES (" & Val(Combo4.Text) & ","
        SQL = SQL + "" & Trim(Val(Text3.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text4.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text5.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text6.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text7.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text8.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo1.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo2.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo3.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo9.Text)) & ","
        SQL = SQL + "" & Val(DTPicker1) & ","
        SQL = SQL + "" & Trim(Val(Combo10.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo5.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo11.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo6.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo12.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo7.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo8.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text9.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text10.Text)) & ","
        SQL = SQL + "" & Trim(Val(Combo13.Text)) & ","
        SQL = SQL + "" & Trim(Val(Text11.Text)) & ")"
''End If
End Sub





此代码无法正常工作。

运行此代码时出现多种错误

请帮忙。



大喊大叫已删除[/编辑]



This code is not working properly.
Many kind of errors occur while running this code
Please help.

Shouting removed[/Edit]

推荐答案


这篇关于通过vb保存新表和更新表中现有记录的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 12:44