Error is using option buttons return value
HI
i m trying to search students record using option button(with 3 options)which opens in a form called frmsearch. Whenever user clicks on one of the option button, there is a label called lblEnter which changes as the per the opt buttons e.g enter student ID etc n user will enter the data in a textbox called txtOpt n my program must extract students information from database called StudentProfile(in ms-access).My code is as follows:
(Note: mdldb is the name of the module where i've connected my interface with database)
Private Sub cmdSearch_Click()
Dim sql As String
On Error GoTo err1
Dim rs As New ADODB.Recordset
mdldb.dbconnect
If lblEnter.Caption = "Enter the Student ID" Then
sql = "select * from StudentProfile where StudentID=" & txtOpt.Text & " "
Set rs = mdldb.conn.Execute(sql)
StdRec.Show
Else
If lblEnter.Caption = "Enter the Student Name" Then
sql = "select * from StudentProfile where FirstName=" & txtOpt.Text & " "
Set rs = mdldb.conn.Execute(sql)
StdRec.Show
Else
sql = "select * from StudentProfile where DateOfBirth=" & txtOpt.Text & " "
Set rs = mdldb.conn.Execute(sql)
StdRec.Show
End If
StdRec.txtID = rs!StudentID
StdRec.txtDob = rs!DOB
StdRec.cmbTitle = rs!Title
StdRec.txtFname = rs!FirstName
StdRec.txtMname = rs!MiddleName
StdRec.txtLname = rs!LastName
StdRec.cmbGender = rs!Gender
err1:
MsgBox Err.Description, vbCritical
End If
End Sub
But my program doesn't go through the queries even if i clicked on the option buttons..it say error "No value given for one or more parameters" n is highligted on sql execution code.
I would be really grateful if anyone could help me with this
thanx
Ana
|