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

Access 2007 Help needed

Hi
I dont know if it is possible or not. I need to do following in a single table database designed in accecc 2007. I have designed form. Everythign is working fine.
I want to add following things:-
1-I want to add a field that automatically assign label to record based on their primarykey. e.g. if record number is between 1 and 50, an entry "1-50"is automatically assigned in a new feild "Group". The feild "Group" is already there in the table. If record is between 51 to 100 then entry entered to be "51-100" and so on. How can I do it.?

Thanks
Apr 7 '08 #1
2 1023
mshmyob
904 Expert 512MB
The first thing I would like to point out is that ACCESS does not use Record Numbers. What you see at the bottom are not really record numbers.

Took me awhile to work this out but here it is. The key point you must remember when using the code is that you MUST ALWAYS open the table in the EXACT same sort order all the time. Since ACCESS does not use record numbers if you open the table with a different sort order you will get different results.

Expand|Select|Wrap|Line Numbers
  1.     Dim rs As Recordset
  2.     Dim vPK As Variant
  3.     Dim vRecNum As Long
  4.     Dim vNewValue As String
  5. ' create a recordset     
  6. Set rs = Me.RecordsetClone
  7. ' populate the recordset - you must do this
  8.     rs.MoveLast
  9.     rs.MoveFirst
  10. ' end populating recordset
  11.  
  12. ' when user moves through the records I want to store the primary key each time from the main form
  13.    vPK = Me.txtYourPK
  14. ' move through the recordset to the matching primary key from main form
  15.     rs.FindFirst "[txtYourPK] = " & vPK
  16.  
  17. ' grab the 'record number'   
  18.     vRecNum = rs.AbsolutePosition + 1
  19.  
  20. ' run your select case to determine what to put in your field
  21.     Select Case vRecNum
  22.         Case Is <= 50
  23.             vNewValue = "1-50"
  24.         ' put all your other CASE's here
  25.         Case Else
  26.     End Select
  27.  
Put this code in the ONCURRENT event or a Button click or wherever you want it run.

Thanks for the challenge this was an interesting one.

cheers,

Hi
I dont know if it is possible or not. I need to do following in a single table database designed in accecc 2007. I have designed form. Everythign is working fine.
I want to add following things:-
1-I want to add a field that automatically assign label to record based on their primarykey. e.g. if record number is between 1 and 50, an entry "1-50"is automatically assigned in a new feild "Group". The feild "Group" is already there in the table. If record is between 51 to 100 then entry entered to be "51-100" and so on. How can I do it.?

Thanks
Apr 8 '08 #2
mshmyob
904 Expert 512MB
This is an addendum to my previous post.

I would strongly suggest you not to use 'Record Numbers' with Access since it is not consistant and you are asking for trouble in the future (in my opinion).

cheers,
Apr 8 '08 #3

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

Similar topics

37
by: jasmith | last post by:
How will Access fair in a year? Two years? .... The new version of Access seems to service non programmers as a wizard interface to quickly create databases via a fancy wizard. Furthermore, why...
1
by: Lyle Fairfield | last post by:
Today I asked Access 2007 to compact db1.mdb. Access 2007 showed a message to me that I did not read carefully; my recollection is that it said it could not save the compacted copy as db1.mdb,...
29
by: Paul H | last post by:
Why the heck was this dropped? All my dbs use ULS even the complex ones. It aint perfect, it's too fiddly, but it works. How will I be able to say "These users can run these reports and these...
1
by: Eugene | last post by:
Hello All, I need a report in Access 2007 to show a dynamic image on every page. I have a table, and I store image's path in a cell in each of the rows. In 2003, I was able to do that using...
2
by: bobdydd | last post by:
Hi All I am currently rebuilding one of my Access 2000 applications in Access 2007. On the Access 2000 application I had 2 Tool bars and a shortcut menu on most of the forms/reports 1. A...
17
by: Neil | last post by:
A client of mine likes some of the new bells and whistles in Access 2007, and is thinking about converting our A03 format MDB to an A07 format file. However, while some of the users have A07, many...
16
by: Neil | last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text feature does not support: a) full text justification; b) programmatic manipulation. I was hoping that someone might...
3
by: cwoll | last post by:
Hi I need help. I have a ms access 2003 database that I would like to upgrade to ms access 2007. The first time I opened I had to fix a few references it wanted a DAO2535.TLB file witch I gave it,...
3
by: anthony | last post by:
I am going to have to start holding jpg files (about 6,000 - 10,000 a year) in our school database. Mainly, they will end up being printed as part of the children's profiles ie via a report. I...
12
by: pballou | last post by:
The is a simple example of code that worked in access 2003 but does not in access 2007. I have checked it with the debugger and the reason is the value of formField1 does not change in ver. 2007...
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
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: 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
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,...
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.