473,408 Members | 2,113 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,408 software developers and data experts.

Using a query with a form reference in DAO

I am trying to use a query with a form reference in DAO, but it does not return any records. Here is my code:

Expand|Select|Wrap|Line Numbers
  1. Dim db As DAO.Database
  2. Dim qdf As DAO.QueryDef
  3. Dim rs1 As DAO.Recordset
  4.  
  5.     Set db = CurrentDb()
  6.     Set qdf = db.QueryDefs("qry_Species_by_park_by_year")
  7.     qdf.Parameters(0) = Forms!Occu_formatting!Park
  8.     qdf.Parameters(1) = Year(Forms!Occu_formatting!survey_begin_date)
  9.     qdf.Parameters(2) = Forms!Occu_formatting!obs_inits
  10.     Set rs1 = qdf.OpenRecordset
  11.  
  12.     If rs1.RecordCount = 0 Then
  13.         MsgBox ("No records in query")
  14.         Exit Sub
  15.     End If
I have a suspicion it might be because I am trying to use the Year function.

Also, when I run the query with the same parameters in Access I get exactly what I need.
Mar 24 '14 #1
1 1049
I solved my own problem!

The answer is that the Year function was causing the problem. To get around this issue, I created an invisible unbound text box in the form that got the year from the date field. Everything else stayed the same except removing the year function from the qdf.paramters(1) line and reassigning it to my new invisible text box.
Mar 24 '14 #2

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

Similar topics

3
by: Mike Cocker | last post by:
Hello, I'm quite weak at PHP, so I was hoping to get some help understanding the below code. First off, I'm trying to create a "query form" that will allow me to display the results on my...
5
by: David Lozzi | last post by:
I am using an upload util and I was told I need this option, enctype="multipart/form-data", in my FORM tag. How do I reference the other form fields within the form from ASP? THanks, --...
3
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
3
by: StBond | last post by:
Hi everyone, I am new to Access and Visual Basic so things my be getting across a bit cloudy. I only started using VB for one week. I am having a little problem with the database that I am...
2
by: SMBR via AccessMonster.com | last post by:
I am not completely new to Access, but I have run into a road block in trying to normalize my database. I am not sure if I am using the correct structure here. I have tried to post a few times...
1
by: anshul | last post by:
Can somebody tell me about state management in asp.net using Query Strings. I am just unable to understand this. Anshul
10
by: FNA access | last post by:
Hello to the world of the wise, I am a CSOM student at TRU. I am trying to design a database to improve my understanding. The problem I am having is with setting up a query. I have a Query...
0
by: =?Utf-8?B?VG9ueSBBLg==?= | last post by:
I'm trying to develop a parameter query using Query Builder, the database is Access 2003. I placed a ? in the column to we quered and linked it to a checkbox on the form. When the user selects an...
1
by: gattkisson | last post by:
I am using Access 2002. I have created a query that has a crosstab query linked to it. The query runs fine initially. but I went back to add criteria to the query that is coming from a form and now I...
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.