473,387 Members | 1,512 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,387 software developers and data experts.

Count records in a dao.querydef

121 100+
Hi

I want to be able to count records in a dao.querydef recordset but I keep getting the error message method or data member not found


I have also tried to find out if the recordset is at the EOF either of these metods would work for what I need


Expand|Select|Wrap|Line Numbers
  1. Dim RstQueryCheckCal As DAO.QueryDef
  2.  
  3.  
  4.  
  5.     Set dbsEquipBookLinked = DBEngine.OpenDatabase("\\bert\sessiondata$\equipdata\EquipBooking2007v15Data")
  6.  
  7.     Set frm1 = [Forms]![FrmCalBooking]
  8.  
  9.     strSql1 = "PARAMETERS DateStart DateTime, DateEnd DateTime; " & vbCrLf & _
  10.     "SELECT TimeValue([TblCalendar].[startDate]) AS Expr2, TimeValue([TblCalendar].[endDate]) AS Expr3, TblCalendar.CalendarID, TblCalendar.StartDate, TblCalendar.EndDate, TblCalendar.Location, DateValue([TblCalendar].[startDate]) AS Expr1 " & vbCrLf & _
  11.     "FROM TblCalendar " & vbCrLf & _
  12.     "WHERE (((TimeValue([TblCalendar].[startDate]))>=[dateStart]) AND ((TimeValue([TblCalendar].[endDate]))<=[dateEnd]) AND ((TblCalendar.Location)=[Forms]![FrmCalBooking]![TxtLocation]) AND ((DateValue([TblCalendar].[startDate]))=[Forms]![FrmCalBooking]![TxtStart]));"
  13.  
  14.  
  15.  
  16.      Set RstQueryCheckCal = dbsEquipBookLinked.CreateQueryDef("", strSql1)
  17.  
  18.  
  19.     RstQueryCheckCal.Parameters("dateStart").Value = frm1![TxtStartTime]
  20.     RstQueryCheckCal.Parameters("dateEnd").Value = frm1![TxtEndTime]
  21.     RstQueryCheckCal.Parameters(2) = frm1![TxtLocation]
  22.     RstQueryCheckCal.Parameters(3) = frm1![TxtStart]
  23.  
  24.     If RstQueryCheckCal.RecordCount > 1 Then
  25.  
  26.         'end sub here
  27.  
  28.     End If
Many thanks Phill
Jun 9 '10 #1

✓ answered by NeoPa

Your code creates the new QueryDef. Before you can check how many records are there in the data that currently matches the specification of the QueryDef, it needs to be opened. This could change between runs so until you run it there is no dataset to check. Does that make the situation a bit clearer?

5 7094
NeoPa
32,556 Expert Mod 16PB
It doesn't appear that you have opened your QueryDef anywhere.
Jun 9 '10 #2
phill86
121 100+
Hi Neopa

Sorry what do you mean?

I know its probably really simple but could really use some help on this

Many thanks Phill
Jun 9 '10 #3
NeoPa
32,556 Expert Mod 16PB
Your code creates the new QueryDef. Before you can check how many records are there in the data that currently matches the specification of the QueryDef, it needs to be opened. This could change between runs so until you run it there is no dataset to check. Does that make the situation a bit clearer?
Jun 9 '10 #4
phill86
121 100+
Hi Neopa

Thanks for the reply

Yes it makes it much clearer I have sorted the problem now

thanks for your help
Jun 10 '10 #5
NeoPa
32,556 Expert Mod 16PB
Always a pleasure Phill :)
Jun 10 '10 #6

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

Similar topics

3
by: deko | last post by:
I have a form with a subform datasheet - I need code behind the OnDelete event of the subform: Private Sub Form_Delete(Cancel As Integer) 'do something that depends on which record is deleted...
0
by: Lauren Quantrell | last post by:
I'm using SQL Server backend on an Access 2K front end. I populate a subform: Forms!myForm.myChild.Form.RecordSource = "myStoredProcedureName" On that form is a control where the controlsource is...
3
by: Melissa | last post by:
I have a sales report where the sales are grouped by district. The report is based on a query with criteria for sales date to get the sales in any specified date range. I have code in the Format...
9
by: Vinnie | last post by:
Is it possible to count the number of records / rows currently being displayed in a datagrid with a view to displaying the result and how ? Cheers Vinnie
4
by: Sjef ten Koppel | last post by:
Hi, I've a small problem. I have a table in which one column is date. I want to count the records for statiscs in a temptable grouped by months lets say 12 months back. e.g. month 1 counts 164...
2
by: Pete | last post by:
I need to create a single query (Not a SQL query) against a single table that counts the number of records in the table, where the single field "tmp" contains specific string values If the field...
1
by: Etayki | last post by:
Hi! I am trying to find the number of records stored in my table within a MS SQL database. This is part of a Console Application. Here is my code: Sub RecordCount() Dim cmd2 As New...
5
by: Soccer5 | last post by:
Trying to Count records on a report that meet a certain criteria. Have a text box in the Report Footer that has the following in the Control Source: =Count(="S") This does not work. It...
6
markrawlingson
by: markrawlingson | last post by:
Hopefully someone can help me out with this, it's driving me nuts... I have two tables - We'll call them table1 and table2. Table1 holds event information, and table2 holds user registration data...
4
by: AccessHunter | last post by:
Hi, I have a table with the type of data as below, sorted as follows, Case (ascending), Loc (ascending) and Transaction Date (ascending). CASE LOC TRANSACTION DATE FACILITY...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.