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

Retrieving Record from Recordset using criteria

171 100+
Hi Guys,
thanks for the great work you are doing

I am working on a database in MS Access and am trying to bring up the last
receipt number in the recordset (its the primary key of the recordset) but am running into this problem, every year the range of the receipts will be different e.g.
2005 it could be 80000 - 90000 while in
2006 it could be 10000 - 20000
meaning that the .MoveLast function would
bring back the last receipt number for 2005. What can I use to get only the range of receipt numbers that I want
here is a sample of my code
Expand|Select|Wrap|Line Numbers
  1. Public rst As New ADODB.Recordset
  2. Dim lngNS4Reciepts as Long
  3. Select Case tbOfficeID 'text box in form
  4. Case 4 'for office number 4
  5.  'tblJobDetailsNS4 is table with RcptID as primary key for office 4
    rst.Open "tblJobDetailsNS4", cnn, adOpenKeyset, adLockOptimistic
        With rst
              .MoveLast
               lngNS4Reciepts = !RcptID (primary key of tblJobDetailsNS4) 
       End With
    'This gives me incremental receipt numbers
     tbRcptID = lngNS4Reciepts + 1 
     Set rst = Nothing 
Thanks alot
Apr 15 '07 #1
3 1938
MMcCarthy
14,534 Expert Mod 8TB
You need to create a query to limit the returned records and open the query instead of the table.
Apr 16 '07 #2
iheartvba
171 100+
You need to create a query to limit the returned records and open the query instead of the table.
yeah thats what I thought as well, but thats the llooooong way, first I would Interogate the table with a query then, I would have to run an append query to put the data into the table. I was thinking along the lines of instead of moveto.first or moveto.last just say moveto.(number 4****)
Apr 18 '07 #3
pks00
280 Expert 100+
What about this

rst.find "somefield = somevalue", , adSearchBackward
Apr 18 '07 #4

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

Similar topics

8
by: mark | last post by:
Access2000 How do I write a query that combines the CTC field from each record below into one record? I need to concatenate the CTC field with a separator, like below: ...
1
by: Ryan | last post by:
I've got a problem I have't run up against before. I generally test for an empty recordset using BOF and EOF. Today, for the first time I ran into a problem where my recordset shows BOF and EOF =...
2
by: Lyn | last post by:
If I have a form where the RecordSource property is set to the name of a table, then on opening the SingleForm form I can cycle through all the records in the table one at a time via Next and...
5
by: tdmailbox | last post by:
I have a form with a child form. In the child form there is a list of names that can grow quite large. On the parent form I want to display the first name from the child form. I set up a test...
22
by: Br | last post by:
First issue: When using ADPs you no longer have the ability to issue a me.refresh to save the current record on a form (the me.refresh does a requery in an ADP). We usually do this before...
0
by: Andy | last post by:
Hi All. I'm working for a company that has set out a guideline for retrieving data from a database. Nobody can explain to me the reason for the following. When retrieving a set of records...
3
by: igendreau | last post by:
I'm trying to clean up a database of mine, and I need to convert some old DAO code over to ADO. When I was using DAO, I had no problem running this script and deleting the record using rs.Delete. ...
9
ADezii
by: ADezii | last post by:
One question which pops up frequently here at TheScripts is: 'How do I retrieve data from a Recordset once I've created it?' One very efficient, and not that often used approach, is the GetRows()...
3
ADezii
by: ADezii | last post by:
Last Tip, we demonstrated the technique for retrieving data from a DAO Recordset, and placing it into a 2-dimensional Array using the GetRows() Method. This week, we will cover the same exact Method...
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: 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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.