The first step of opening the computer room charging system is to tap the registration window^_^
1, The code logic and code ideas of the registration form are as follows:
2, Error set:
This error prompt will pop up after registering the form input:
The above reason is that null value is not allowed
Let's take a look at the data in the Student table in the database
The fields of ischeck, date, time, and type are all set to be NULL values. There is no problem in assigning values to each field in the data bar table.
3, Query set
How to save the current time of the computer into the database in a certain format?
Time format:
Format(Now(),"HH:mm:ss")
Date format:
Format(Now(),"yyyy/MM/dd")
The code is as follows:
mrc.Fields(12) = Format(Now(), "yyyy-MM-dd") mrc.Fields(13) = Format(Now(), "HH:mm:ss")
4, Code snippet
1. Composition control content input code snippet:
Private Sub Form_Load() combosex.AddItem "male" combosex.AddItem "female" combostatus.AddItem "Use" combotype.AddItem "Fixed user" combotype.AddItem "Temporary users" End Sub
2. Text box insert data update to database snippet:
Private Sub cmdsave_Click(Index As Integer) Dim txtSQL As String Dim MsgString As String Dim mrc As ADODB.Recordset txtSQL = "select * from student_Info" Set mrc = ExecuteSQL(txtSQL, MsgString) mrc.AddNew mrc.Fields(0) = Trim(txtcardno.Text) mrc.Fields(1) = Trim(txtstudentNo.Text) mrc.Fields(2) = Trim(txtstudentname.Text) mrc.Fields(3) = Trim(combosex.Text) mrc.Fields(4) = Trim(txtdepartment.Text) mrc.Fields(5) = Trim(txtgrade.Text) mrc.Fields(6) = Trim(txtclass.Text) mrc.Fields(7) = Trim(txtcash.Text) mrc.Fields(8) = Trim(txtexplain.Text) mrc.Fields(9) = "1" mrc.Fields(10) = Trim(combostatus.Text) mrc.Fields(11) = "Outstanding accounts" mrc.Fields(12) = Format(Now(), "yyyy-MM-dd") 'Get current date, fixed date format mrc.Fields(13) = Format(Now(), "HH:mm:ss") 'Get current time, fixed time format mrc.Fields(14) = Trim(combotype.Text) MsgBox "login was successful!", vbOKOnly, "reminder:" mrc.Update mrc.Close
Note 1: mrc.Fields(9) is the userID. Because the login form has not been made yet, a data is temporarily entered first^_^
Note 2: the above code has not been completed yet. At this stage, it is only to let the program run first, and there is no restriction on the text box
3. Clear code snippet:
Private Sub cmdclear_Click(Index As Integer) txtcardno.Text = "" txtstudentNo.Text = "" txtstudentname.Text = "" txtdepartment.Text = "" txtgrade.Text = "" txtclass.Text = "" txtcash.Text = "" txtexplain.Text = "" txtrechargecash.Text = "" End Sub