Printing of only current record of a report from a form. (1 Viewer)

Imranis

Registered User.
Local time
Today, 04:55
Joined
Sep 11, 2000
Messages
26
I have one one form named "Inventory" . From the mdb file of this form a query and a report was created named ''sticker''. I enter data through form and there are about 700 hundred entries of record. I wish to print only the ''current record'' on the form. When I run micro, it starts printing all the record from 1 to somany dozens. Can somebody please help me in preparing code for this micro so that only current record can be printed from the form. Thanks.
 
R

Richie

Guest
Look back through previous posts on this forum there are many examples to help you.
 

Imranis

Registered User.
Local time
Today, 04:55
Joined
Sep 11, 2000
Messages
26
Thank you Mr. Richie. On your advice I checked the old posts and tried to make a code but could not succeed. I am new with Access 97. My form name is Inventory. My report name is 'sticker'. Table does not have any relationship with another table. In fact I have only one table without any primary key etc. With the help of printrecord command button, I wish to to print the current record of report, which has been created with some fields from the form. The number of entries on this form are many. If I use this printrecord command button all records start printing. I have tried to use the following code:

Private Sub printrecord_Click()
On Error GoTo Err_printrecord_Click


DoCmd.OpenReport "Sticker", acViewNormal, (I do not know what to add for "[IDField]= Becuase I do not what ID field is. Can, please someone write it down completely.


Exit_printrecord_Click:
Exit Sub

Err_printrecord_Click:
MsgBox Err.Description
Resume Exit_printrecord_Click

End Sub

Can any body please write full code. I may mention again that I have no previous knowledge of Access specially of code building. My only problem is that by pressing print record button on form ''only current record of the report 'sticker' may be printed'' Thanks.
 

Robert Dunstan

Mr Data
Local time
Today, 04:55
Joined
Jun 22, 2000
Messages
291
Although you say you do not have a primary key do your records contain a unique field so that you can identify individual records?

If you have then you can create a query based on your table and include all the fields. In the criteria section for the unique field you can use this expression =[Forms}![Inventory]![FieldName] (FieldName will be the name of your field). Save the query, then go into the design of your report and display the reports properties. Under the 'Data' tab set the record source to the saved query and save your report.

Now when you click your print record button in your form the report will open using the query and because you set criteria in the query to match the form it should only print the current record displayed in the form.

If you need more help then just post again
 

Imranis

Registered User.
Local time
Today, 04:55
Joined
Sep 11, 2000
Messages
26
Dear Mr. Robert Dunstan,
Thanks for your reply. Honestly I do not understand what is Unique Field. If this is the same as Primary Key Field, then I do not have that in my Table. I have fields like, VoucherNo, Date, Agentname, Typeofitem, stickerno , etc. I have not allotted to any field Primary Key, becuase I have one table and no reltionship with another table. Is it possible to print current record without Primary Key or Unique Field, (if they both are the same). Thanks for your reply.
 

Robert Dunstan

Mr Data
Local time
Today, 04:55
Joined
Jun 22, 2000
Messages
291
OK what I should have said was unique data.
By this I mean in your table does each record contain some data that is unique to that record. For example you mention voucher number. Is this number different for each record? If it is then this can be used as your unique field to identify that record when you want to print. It does not matter that you don't have a primary key at this stage.

Post again if you need more help
Rob
 

Imranis

Registered User.
Local time
Today, 04:55
Joined
Sep 11, 2000
Messages
26
Dear Mr. Robert,

Thanks a lot for your help with which the problem has been solved now. Since I am a new with Access and will appreciate your help and guidance from time to time. Once again thanks.
 

Users who are viewing this thread

Top Bottom