Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 10th, 2006, 10:11 AM
Authorized User
 
Join Date: Mar 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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



 
Old March 10th, 2006, 10:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

try the querys in the database, probably the queries are wrong.. if any field is a string type you need the value in the where between ''.



HTH

Gonzalo
 
Old May 1st, 2006, 03:39 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There are several things you can try.
For example, when building a sql select statement, you must use single quotation marks to enclose strings in the where clause like this:

Code:
sql = "select * from StudentProfile where FirstName='" & txtOpt.Text & "'"

Woody Z http://www.learntoprogramnow.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Check Boxes/Option buttons/Option Group hewstone999 Access VBA 1 March 14th, 2008 07:25 AM
updating text fields with option buttons redtechcoms Access VBA 7 February 2nd, 2006 03:14 PM
Using Option buttons NovieProgrammer Access VBA 1 April 2nd, 2005 09:16 PM
Is one (1) a 'length' for option buttons? John K. King Javascript How-To 2 November 7th, 2004 06:04 PM
Option buttons, queries and combo boxes... Anubis Access VBA 26 November 20th, 2003 12:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.