By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,905 Members | 1,783 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,905 IT Pros & Developers. It's quick & easy.

Print a record number in access report

P: 9
Hi experts! (Waiting for your reply)
I want to print serial number or record number in access report while this field is not included in any table. Please help me
Feb 1 '08 #1
Share this Question
Share on Google+
8 Replies


JustJim
Expert 100+
P: 407
Hi experts! (Waiting for your reply)
I want to print serial number or record number in access report while this field is not included in any table. Please help me
Hi and welcome to The Scripts,

If a serial number is not included in the table then you can't produce it at all. If you base your report on a recordset or query which is ordered in some way, then you can print the ordinal number of the record within the recordset or query.

It all depends on whether you want this number to be absolutely associated with this record or just for reference purposes within the report.

Let us have more information on your application and we'll see what we can do.

Jim
Feb 1 '08 #2

P: 9
I want to print record number in report only for reference. How can I do it?
Feb 1 '08 #3

Expert 100+
P: 446
Hi
You can't print something that doesn't exist !

You will have to create something but what is the point of having a 'serial number' not tied to a record ? Next time you print the item may have a different number??

Access reports do not support Line Numbers (at least I can't find)

You had better give more details

S7
Feb 1 '08 #4

P: 9
Suppose the report is based on query that
SELECT * from employees where age>50

Now I want to print serial number against each selected record in report.

In foxpro a function recno() can do this but in ACCESS i am seeking help.
Feb 1 '08 #5

Expert 100+
P: 446
Suppose the report is based on query that
SELECT * from employees where age>50

Now I want to print serial number against each selected record in report.

In foxpro a function recno() can do this but in ACCESS i am seeking help.
Hi again khursheed
It seems JustJim has your answer at the same time as myself and told you much the same thing. However, if he can get the 'ordinal' number to print in a report then it sound like this is what you really want. I shall wait for his reply because I would like to know more about this too.

Meanwhile, I have been puzzling how you could add line numbers to each record in a report and found that if you have a simple query you could try revising it into an aggregate query and 'count' a unique field;
Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT FirstName, LastName, StaffNo, Age, Count(StaffNo) AS CountOfEmp
  3. FROM employees 
  4. GROUP BY FirstName, LastName, StaffNo, Age
  5. HAVING ((Age>50));
  6.  
If [StaffNo] is unique then [CountOfEmp] should be '1' for every record but when you are in Report Design mode you can change the property of the [CountOfEmp] control to be Running Sum = 'Over all' on the Data tab . This then shows in the Report as 1,2,3 etc for each record.

Of course, this will only work if you have a unique field or you could concatonate a combination of fields eg count([FirstName]&[LastName]&[Age]) but is messy and far better to modify your database to have 'serial numbers' that means something.

S7
Feb 4 '08 #6

JustJim
Expert 100+
P: 407
Hi again khursheed
It seems JustJim has your answer at the same time as myself and told you much the same thing. However, if he can get the 'ordinal' number to print in a report then it sound like this is what you really want. I shall wait for his reply because I would like to know more about this too.

Meanwhile, I have been puzzling how you could add line numbers to each record in a report and found that if you have a simple query you could try revising it into an aggregate query and 'count' a unique field;
Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT FirstName, LastName, StaffNo, Age, Count(StaffNo) AS CountOfEmp
  3. FROM employees 
  4. GROUP BY FirstName, LastName, StaffNo, Age
  5. HAVING ((Age>50));
  6.  
If [StaffNo] is unique then [CountOfEmp] should be '1' for every record but when you are in Report Design mode you can change the property of the [CountOfEmp] control to be Running Sum = 'Over all' on the Data tab . This then shows in the Report as 1,2,3 etc for each record.

Of course, this will only work if you have a unique field or you could concatonate a combination of fields eg count([FirstName]&[LastName]&[Age]) but is messy and far better to modify your database to have 'serial numbers' that means something.

S7
Hi guys,

Sorry to keep you holding your breath, but no I don't have a great answer. If it ain't in there, you can't get it out. My "ordinal number" reply was many based on the concept of a recordset (with an index) and the recordset.absoluteposition.

Remember though that a Primary Key is an internal thing. It should be "meaningless" and "invisible to users". This is important because if a record is deleted in a table a PK between, say, 1003 and 1005 may be missing, it it is "meaningless" and "invisible to users" it will not matter. If the PK was visible to users and somehow meaningful they may be tempted to "replace"it. This can cause all sorts of problems!

Do try to read Mary's wonderful explanation of database normalisation (then read it again in about month or so, it takes a while to sink in)

Jim
Feb 7 '08 #7

Expert 100+
P: 446
Hi Jim
That's a pity. I hadn't heard of 'ordinal' numbers and thought I was going to learn something new. It's a long time since I did dBase and RecNo did seem to ring a bell. But I totally agree with your rationale.

When I did some Unbound forms a while ago I had to keep looking up '.AbsolutePosition + 1' to find the record number as the built-in navigation controls don't work and had to write my own.

If you could base an Access report on a Recordset instead of a Query then this might be a possiblity.... I suppose you would have to define the Recordset name Public then you be able to use it as the Record source. .

I have not tried this before (and too busy today) but do you know if it's possible??

S7
Feb 7 '08 #8

Jim Doherty
Expert 100+
P: 897
Suppose the report is based on query that
SELECT * from employees where age>50

Now I want to print serial number against each selected record in report.

In foxpro a function recno() can do this but in ACCESS i am seeking help.

If all you are wishing to do is print a record number and are not concerned about its ordinal meaning in relation to the data 'other' than showing a sequential number then simply place an unbound textbox in the detail section of the report and set its controlsource to

=[CurrentRecord]

Regards

Jim :)
Feb 7 '08 #9

Post your reply

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