Private Sub Command1_Click ()
Dim conn As New ADODB. Connection
Dim the rs As New ADODB. You
Dim STRSQL As String
STRSQL="select as the call, the call number of child serial number as the serial number, the title as the title, the author as the author, the current status as the current state, by number of borrowed as by borrowing number, date of publication as date of publication, publishing house as publishing house, borrowed time as borrowing time where comes from"
The Select Case True
Case Option1. Value
STRSQL=STRSQL & amp; "Title"
Value
Case Option2.STRSQL=STRSQL & amp; "Call"
Case Option3. Value
STRSQL=STRSQL & amp; "The author"
End the Select
STRSQL=STRSQL & amp; "Like '%" & amp; Trim (txtData) & amp; "% '
"On Error GoTo errorhandle
Conn. Open "BOOK"
Rs. The Open STRSQL, conn
The Set DataGrid1.
the DataSource=rsDataGrid1. Refresh
Errorhandle:
If Err. The Description & lt;> "" Then
Mdgbox Err. The Description
The Exit Sub
End the If
End Sub
Ask is why,, so hard
CodePudding user response:
Compiler error message prompt is! Will point out which line is wrong,Below to help you correct the
errorhandle:
If Err. The Description & lt;> "" Then
MsgBox Err. The Description '& lt; -
The Exit Sub
End the If
CodePudding user response:
STRSQL=STRSQL & amp; "Like '%" & amp; Trim (txtData) & amp; "% '"Like adding space
STRSQL=STRSQL & amp; "Like '%" & amp; Trim (txtData) & amp; "% '"
CodePudding user response:
The an idea:As the name in the front and rear of the as still as a what?
The field name in Chinese in the future, waiting for the debug.
The Select Case True written as you really understand?
And
Case Option1. Value
STRSQL=STRSQL & amp; "Title"
Value
Case Option2.STRSQL=STRSQL & amp; "Call"
Case Option3. Value
STRSQL=STRSQL & amp; "The author"
Such hard-coded really good?
Error message made it clear, is that you use the undefined function or procedure (and possibly variable name), do you still put on error commented this.
Finally, the connecting database, query record of all these things are placed in a small button event properly?
Waiting for your data, and then met a fine nothing like more a few times, you die this program can not run?
Oh, a novice... That's ok, write down slowly, you will trample the pit again!
CodePudding user response:
Oh, seems to be a novice, I also say something aboutOne, STRSQL="select as the call, the call number of child serial number as the serial number, the title as the title, the author as the author, the current status as the current state, by number of borrowed as by borrowing number, date of publication as date of publication, publishing house as publishing house, borrowed time as borrowing time where comes from"
The string read the stranger, as same as before and after, don't know what intention, as such be clear at a glance:
STRSQL="select * from library where" simple and clear, but only can retrieve all of the fields
Two, the Select Case True 'is this True VB keyword cannot be used as variable!!!!!
Case Option1. A Value of '| ha ha, have such a...
STRSQL=STRSQL & amp; "Title"
Value
Case Option2.STRSQL=STRSQL & amp; "Call"
Case Option3. Value
STRSQL=STRSQL & amp; "The author"
End the Select
Sets the Option1 controls to an array of controls, Option1 (0), Option1 (1), Option1 (2)
Dim XX As Ineger
XX=Option1 (Index). The Index
The Select Case XX
Case 0
STRSQL=STRSQL & amp; "Title"
Case 1
STRSQL=STRSQL & amp; "Call"
Case 2
STRSQL=STRSQL & amp; "The author"
End the Select so there should be no problem
Three, conn. Open "BOOK" conn is the need to connect to the database, do not understand you what is this "BOOK" string
Should be conn. Open ". The Provider=Microsoft Jet. The OLEDB. 4.0; Data Source="& amp; App. The Path & amp; "\ aaa. MDB; Persist Security Info=False "
It is connected to the Access database connection string, database connection is aaa. MDB database
Four, STRSQL=STRSQL & amp; "Like '%" & amp; Trim (txtData) & amp; "% '
"Should be STRSQL=STRSQL & amp; "Like '%" & amp; Trim (txtData. Text) & amp; "% '" pay attention to the string must be Spaces, new attributes (controls.) this writing habit
CodePudding user response:
The