Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a report from the record I am on

Status
Not open for further replies.

ferrisj

IS-IT--Management
Dec 7, 2004
79
US
I am creating a very small inventory database. I have a form that has user information on it, and a subform that has the inventory option they can fill. I am going to create a button from teh button wizard that says send report. I would like the report that is sent to be specific to the record I am on.

For example.

I find my record and my name is larry, When I fill in my inventory info and click send, I want a one page report to be sent that just shows larrys information, not everyone's.

Thanks
 
Use the "Where" argument of OpenReport.
 
ok, I may need a bit more explanation than that. sorry
 
I have:
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click

Dim stDocName As String

stDocName = "rptInventory",
DoCmd.SendObject acReport, stDocName

Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End Sub
***********************************************

Do I type stDocName = "rptInventory", Where Currentrecord=ReportREcord
 
Sorry, I did not catch the 'send' part [blush]

You can create a report based on a query that references the current form. The SQL might look something like this:

[tt]Select Id, This, That From tblTable Where Id=Forms!frmForm!txtID[/tt]

Or

[tt]Select Id, This, That From tblTable Where Id=Forms!frmForm!SubFormControlName!Form!txtID[/tt]



 
And where in the above code do I type this?


Select Id, This, That From [Inventory] Where Id=Forms![Inventory Form]![Inventory subform]!Form![CODIGO USUARIO]
 
It should go in the query (SQL View) that the report is based on.
 
I am going to need this spelled out for me. the report is based on a table, and I do not write in SQL. I use the query builder.

 
One of the options for the query builder is SQL View (Design View, Datasheet View, SQL View), it is very useful, especially for sites such as this.

However, you can use the design grid to build a query from your table and just add the form reference to the criteria line:

[tt]=Forms![Inventory Form]![Inventory subform].Form![CODIGO USUARIO][/tt]

It is generally recommended that forms and reports are based on queries, rather than tables.
 
for those not familiar with VBA it is best working with the wizard to produce the code. It is much easier,

Ian Mayor (UK)
Program Error
9 times out of 10 I know what I'm talking about. This must be my tenth reply.
 
ProgramError
This is for SQL in the query design window, I think you must mean the Expression Builder yesno?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top