Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 7th, 2005, 09:39 AM
leonepaolo leonepaolo is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 1 leonepaolo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 m 2 sec
Reputation Power: 0
Run an Access Query in VB

Hi,

I'm using VB6 and Access 2003.

I have a Query that ask me for the "Name" (field) I want to search and the "Date" range I want to search - this query has input boxes for me to insert my paramaters.

From within Access the Query does this
Enter Name
Enter Start Date
Enter End Date

The Code for the name criteria is: [Enter Name]
The code for the date criteria is: Between [Enter Start Date] And [Enter End Date]

How do run this query from within VB?
Can I return the results to a recordset?

Would it be better to create a create query in VB? If yes then how and what do I do with it.

Any help would be appreciated and if possible, I'd love an example.
Paolo

p.s. I use run time ado to open my recordset and I'm used to opening my queries and tables like this:
dcn.CursorLocation = adUseClient
dcn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & constDataFolder & const_mdbFileFormat & strDcn & constFileExtension

Set rs = New ADODB.Recordset
rs.CursorType = adOpenKeyset
rs.LockType = adLockPessimistic
rs.Open strTable, dcn

Reply With Quote
  #2  
Old March 11th, 2005, 05:51 AM
hithere's Avatar
hithere hithere is offline
Learner
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: India
Posts: 450 hithere User rank is Sergeant (500 - 2000 Reputation Level)hithere User rank is Sergeant (500 - 2000 Reputation Level)hithere User rank is Sergeant (500 - 2000 Reputation Level)hithere User rank is Sergeant (500 - 2000 Reputation Level)hithere User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 12 h 13 m 21 sec
Reputation Power: 17
U can use three textboxes in VB one for the "Name" field and the other two for Date range. In the query simply use the value of textboxes. For the Date range u might have to convert the date in a format which the database is having then only records will be retreived.
Run the query as
rs.open "Select * from tblname where Name = '" & text1.text & "' and Date1 between #" & date1 & "# and #" date2 & "#", dcn
date1 and date2 contains the dates in database recognized format.

I hope this will help u
For the date u can also use dtpicker control. this u will find in components.
Comments on this post
nofriends agrees!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Run an Access Query in VB


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway