Home > Software engineering >  Very urgent! IF use to judge record set a field rs. Fields (" status ") values conform to
Very urgent! IF use to judge record set a field rs. Fields (" status ") values conform to

Time:10-04

In order to realize the function:
In the text box (text1 and text2) repeat input employee number
Search employees table (tb_person), if you search the number above, and the status field is not a "left", the staff authentication is successful, or show "employees have left," or "serial number input error"

Table is as follows:
000001 John 67801512 male
000002 Jane 67801513 female
000003 Mary 55662222 female
000004 Tony 13526252632 male leave

no matter which number, I input the above all is a successful authentication, but clearly has left 000004

Rs2. Open the "select * from tb_person where no='" & amp; Text1. Text & amp; "' and no='" & amp; Text2. Text & amp; "'", CNN, adOpenKeyset, adLockOptimistic

If rs2. RecordCount & lt; 1 Then
MsgBox "number wrong or don't match"
Text2. Text=""
Text1. Text=""
Text1. SetFocus
The Else
If rs2. RecordCount=1 Then
If rs2. Fields (" status "). The Value & lt;> "Departure" Then
MsgBox "employee proves successful,"
Frame1. Visible=True
Text1. Enabled=False
Text2. Enabled=False
Text3. SetFocus
The Else
MsgBox "employees, who left number failure"
Text2. Text=""
Text1. Text=""
Text1. SetFocus
The Exit Sub
End the If

End the If
End If

CodePudding user response:

 If rs2. RecordCount=1 Then 
The Debug. Print Len (rs2 Fields (" status "). The Value) 'check the length of the text, it is estimated that there are Spaces'
If the Trim $(rs2 Fields (" status "). The Value) & lt;> "Departure" Then 'go to space to compare

CodePudding user response:

 if trim (text1. Text) & lt;> Trim (text2. Text) then 
Msgbox "the two input Numbers don't agree!" , 48, "tip"
The exit sub
The else
If rs2. State<> Adstateclosed then rs2. Close
Rs2. Open the "select * from tb_person where [no]='" & amp; Trim (text1. Text) & amp;" 'and status<> 'departure', "adopenkeyset, adlockreadonly
If rs2. Recordcount=0 then
Rs2. Close
Msgbox "input number does not exist or have left!" , 48, "tip"
The exit sub
The else
.
End the if
End the if

CodePudding user response:

This is a typical database design is not reasonable.

You open the database table staff can see a pile of "left" or "on-the-job",

Better way is to set the status to numeric, then build a alone Staff_Status table corresponding to the specific content of the status value. Even if in the future to add or modify state employees, only need to modify a record Staff_Status table
  • Related