|
-
Aug 25th, 1999, 06:30 PM
#1
Thread Starter
Hyperactive Member
I've never done much database work with VB, but I need to do the following:
Have users enter 2 numbers in text boxes. Then run a query on an access table where it returns all data between those 2 numbers.
Can someone point me in the right direction?
Thanks!!
------------------
Morgan
[email protected]
My Web Page
-
Aug 25th, 1999, 07:20 PM
#2
Lively Member
You'll have to modify this code to suit your database, but here goes
have the two text boxes called text1 and text2.
Enter the following code in the event you are going to use to query the data base (eg a button click)
dim sql as string
dim mydatabase as database
dim myrecordset as recordset
set mydatabase = opendatabase("path to the database",false,false)
sql="Select * from mytable where myfield1>=" & val(text1.text) & " and myfield2>=" & val(text2.text)
set myrecordset = mydatabase.openrecordset(sql)
now just use the myrecordset object the same as a VB data control.
Remember that if you want to use the recordset outside of this procedure you'll have to publicly declare it at the top of the module or form
Cheers
Chris
-
Aug 25th, 1999, 07:32 PM
#3
Thread Starter
Hyperactive Member
Thank you very much!!
------------------
Morgan
[email protected]
My Web Page
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|