473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Help with qdf.OpenRecordset

Hello,

Access VBA newbie here and need a little help getting this to work. I have a select query set up with two parameters on one field so I can use a date range:

Between [Start Date] And [End Date]

This works just fine when running the query all by itself.

I have created a form which allows the user to enter the Start Date and End Date and then runs the query when selecting a button. The problem I'm having is no results show up. The code runs through but doesn't display even an empty results page.

My code is below. The message box fires at the end but nothing displays on the screen prior to that. I've tried using ("Start Date") and ("End Date") in place of (0) and (1) for the parameters and that doesn't work either.

I've also checked the me.StartDateTB and me.EndDateTB values and they are correct.

Any help you could give me would be appreciated.


Expand|Select|Wrap|Line Numbers
  1. Private Sub RunBtn_Click()
  2.  
  3.     Dim db As DAO.Database
  4.     Dim qdf As DAO.QueryDef
  5.     Dim rst As DAO.Recordset
  6.  
  7.         Set db = CurrentDb
  8.         Set qdf = db.QueryDefs("TestStep1")
  9.             qdf.Parameters(0) = Me.StartDateTB
  10.             qdf.Parameters(1) = Me.EndDateTB
  11.         Set rst = qdf.OpenRecordset
  12.  
  13.         MsgBox "finished"
  14.  
  15. End Sub
  16.  
Feb 10 '12 #1
5 4152
ADezii
8,834 Expert 8TB
What would you expect to disply on Screen? Is is a Recordset Object you are trying to create, not a Querydef Object. A recordset has no visible Interface.
Feb 10 '12 #2
All I'm really trying to do is use entries from two textboxes in a form as the parameters for a query that is already set up in Access. Then display the results on the screen.

thanks for any and all help.
Feb 13 '12 #3
NeoPa
32,556 Expert Mod 16PB
As ADezii said, opening a Recordset does Not cause the data to display on the screen.
Feb 13 '12 #4
@NeoPa

NeoPa,

I understand that now. I am still trying to find a way to accomplish my goal. After ADezii's response, I googled around some more and tried the following but it still displays nothing.

All I would really like to know is how to display the results of TestStep1 with the parameters from the form.

Thanks in advance for the help.


Expand|Select|Wrap|Line Numbers
  1.         Dim db As DAO.Database
  2.         Dim qdf As DAO.QueryDef
  3.         Dim rst As DAO.Recordset
  4.  
  5.         Set db = CurrentDb
  6.         Set qdf = db.QueryDefs("TestStep1")
  7.             qdf.Parameters(0) = Me.StartDateTB
  8.             qdf.Parameters(1) = Me.EndDateTB
  9.         Set rst = qdf.OpenRecordset
  10.  
  11.         Do Until rst.EOF
  12.             Debug.Print rst!VENDOR_CARRIER_ID
  13.             rst.MoveNext
  14.         Loop
  15.  
  16.         MsgBox "finished"
  17.  
  18.  
Feb 13 '12 #5
NeoPa
32,556 Expert Mod 16PB
I'm not aware that you can pass parameter values to a QueryDef object when you open it for display. What you can do though, is to design the QueryDef to get it's values from a form instead.
Feb 13 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: el Benno | last post by:
If CurrentDb.OpenRecordset("table").EOF Then ... works fine If CurrentDb.OpenRecordset("Query").EOF Then ... doesn't????????? microsft help is outstanding too - surprise surprise any help...
5
by: Philippa | last post by:
I'm trying to access data in vba using the openrecordset command. The data in on a SQL Server 2000 database, and I have linked tables to that data. the Table I'm trying to access is one of these...
0
by: Bobbak | last post by:
Hello All, I could really use some help with this bit of code I am working on, every time I come to execute it I get an error that says "Compile Error: Argument not optional". Now I am using...
9
by: tym | last post by:
HELP!!! I'm going round the twist with this... I have a VB6 application which is using DAO to access a database (Please - no lectures on ADO, I know what I'm doing with DAO!!) Ok, problem...
8
by: Russell Potter | last post by:
I'm trying to create a recordset using "currentDB.OpenRecordSet", using a query as the "source" string (the only parameter: so all the others are set to their defaults which, I believe, means...
0
by: AR Hall | last post by:
This code goes through 3 work sheets in the same XL workbook, day, eve and night shift in each sheet their are columns representing production work orders and reject and downtime for each order...
0
by: mo. | last post by:
I need some help in accessing Jet database using DAO. I have just started to learn c# and am trying to rewrite a program I have in vb.net to c#. In VB.Net I can do this: Dim ws As...
5
by: Sunnyrain | last post by:
I am developing a program in Access 2000. I couldn't make OpenRecordset method work right. It's working when I opened a simple SQL query below in OpenRecordset. ..... Dim dbs As Database, rst...
1
by: corsibu | last post by:
hello , i just wanted to ask if there's anyone who could help me do the following thing : i have an empty temporary table, this table will have a row filled with data grabbed by a querry at this...
7
by: mirandacascade | last post by:
The questions are toward the bottom of this post. Situation is this: 1) Access 97 2) Multi-user appplication 3) SQL Server 2000 4) Sporadically (i.e. less than 1% of the time) encounter the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.