|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Run an Access Query in VB |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|