A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

updating a field with a count



 
 
Thread Tools Display Modes
  #1  
Old June 26th, 2008, 08:40 PM posted to microsoft.public.access.queries
Greg
external usenet poster
 
Posts: 748
Default updating a field with a count

I have a auction database where I have x number of steers, y number of lambs,
z number of rabbits, etc. After I get the database in order I would like to
automate the sale_order field with the sale number for each animal within
each species (so steers run from 1 to x, lambs run from 1 to y, etc). Is
there an way to do this using update queries.

Thanks for any help.
  #2  
Old June 27th, 2008, 12:51 AM posted to microsoft.public.access.queries
bhicks11 via AccessMonster.com
external usenet poster
 
Posts: 529
Default updating a field with a count

Hi Greg,

Could you please try explaining that in a different way. Having trouble
understanding the problem.

Bonnie
http://www.dataplus-svc.com

Greg wrote:
I have a auction database where I have x number of steers, y number of lambs,
z number of rabbits, etc. After I get the database in order I would like to
automate the sale_order field with the sale number for each animal within
each species (so steers run from 1 to x, lambs run from 1 to y, etc). Is
there an way to do this using update queries.

Thanks for any help.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200806/1

  #3  
Old June 27th, 2008, 12:30 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default updating a field with a count

Possibly. More details about the structure of your table is required.

For instance, I assume you have a field that hold the animal type - steers,
lambs, etc.

Do you have a primary key field (one that puts the records in a unique order)-
an autonumber field for instance?

What you are looking for is a ranking query.
This sample query assumes that AnimalType is a text field and the Primary Key
Field is a number field.

UPDATE tblAnimals
SET Sale_Order = DCount("*","tblAnimals","AnimalType='" & [AnimalType] & "'
AND [PrimaryKeyField] " & [PrimaryKeyField]) + 1

Your other option is to write a VBA function that will set the numbers
incrementally.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

bhicks11 via AccessMonster.com wrote:
Hi Greg,

Could you please try explaining that in a different way. Having trouble
understanding the problem.

Bonnie
http://www.dataplus-svc.com

Greg wrote:
I have a auction database where I have x number of steers, y number of lambs,
z number of rabbits, etc. After I get the database in order I would like to
automate the sale_order field with the sale number for each animal within
each species (so steers run from 1 to x, lambs run from 1 to y, etc). Is
there an way to do this using update queries.

Thanks for any help.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.