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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Continious forms for printing reports 2

Status
Not open for further replies.

waymond

Programmer
Mar 1, 2005
118
US
I give up on list boxes tp difficult way to difficult.

I have a query that is used by a form and a report. I am using a continious form. I need the user to click the command button next to the object and only print the report for the object that the command button is next to. There are several objects and only one report. Right now it just wants to print everything.

Tony
 
Tony
I'm not clear what you are trying to print, as you mention "several objects and only one report." What are you calling "objects?"

Can you say a little more about your continuous form, and what controls are on it?

Are you trying to set criteria from the form - such as picking a date, or customer?

Also, at the start of the post you mention list boxes. Are they playing a part in your difficulty?
Tom
 
yes an object is actually a name lets say of tables that are in the as400 system for this company.
like
Arnight
cmxlau45
Voo1cR

So the report is grouped so that when the ObjectID changes the name of the object changes it forces the next object to start on a fresh page.

So I created a continious form that now list the objects from the Object Query
so I have
ARNIGHT with command button
CMXLAU45 with command button
Voo1cr with command button

I need to know how to get the command button to only print the report with the object it is for. Like ARNIGHT how can I get it so that when the user clicks that command button it only prints for the object arnight
no I stopped trying the listbox it became way to difficult for my level
thank you
 
Tony
I'm assuming that the code behind the command button might be something such as...
DoCmd.OpenReport "YourReportName", acPreview
or maybe acNormal if you are wanting to Print without Preview

You need to add a WHERE clause to the end of the command line, so it would look something like...
DoCmd.OpenReport "YourReportName, acPreview,,"[ObjectID] = ' " & ARNIGHT & " ' "

Try that. It assumes that the ObjectID is ARNIGHT or CMXLAU45 or whatever. If the name of the control is something different, you will have to fix it.

Tom
 
Should I do this for every command button or is there a way to dynamically do this because on the form in design view it is just one command button


thank you
 
Tony
Looks as if I misintrepreted your post to indicate you had 3 command buttons.

So what you need to do is change the WHERE clause so that it picks up whatever has been selected. Access needs a way of knowing which ObjectID is selected.

DoCmd.OpenReport "YourReportName", acPreview,, "[ObjectID] = ' " & Forms!YourFormName!YourControlName & " ' "

By YourControlName I mean the control that is selected.

By the way, you may need to remove the spaces between the single quote (') and the double quotes (") as I put them there only for clarity purposes.

Post back with more information if this doesn't get close.

Tom
 
getting close why do I get the datatype mismatch in criteria expression with the following code:

Private Sub Command15_Click()
On Error GoTo Err_Command15_Click


DoCmd.OpenReport "UpdatedRptonQuery", acPreview, , "[ObjectID] = '" & Forms![ObjQry1]![ObjectID] & "'"



Exit_Command15_Click:
Exit Sub

Err_Command15_Click:
MsgBox Err.Description
Resume Exit_Command15_Click


End Sub

Thank You
 
Tony
Is the ObjectID text or a number?

Anyway, try it this way...
DoCmd.OpenReport "UpdatedRptonQuery", acPreview, , "[ObjectID] = [Forms]![ObjQry1]![ObjectID]"

Tom
 
so close now I get the report but it still is all the reporting starting at arnight for every button my code is this

Private Sub Command15_Click()
On Error GoTo Err_Command15_Click


DoCmd.OpenReport "UpdatedRptonQuery", acViewPreview, "[ObjectID] = ' " & Forms![ObjQry1]![ObjectID] & " ' "
Debug.Print



Exit_Command15_Click:
Exit Sub

Err_Command15_Click:
MsgBox Err.Description
Resume Exit_Command15_Click


End Sub
 
ObjectID is an autonumber field

thank you
 
Tony
Okay, if the ObjectID is a number field, then you have to remove the single quotes as they delimit text.

Try what I suggested two posts ago.
DoCmd.OpenReport "UpdatedRptonQuery", acPreview, , "[ObjectID] = [Forms]![ObjQry1]![ObjectID]"

Alternatively...
DoCmd.OpenReport "UpdatedRptonQuery", acPreview, , "[ObjectID] = " & [Forms]![ObjQry1]![ObjectID] & ""

If this doesn't work, it means that we aren't sufficiently selecting an individual ID because of the use of the continous form.

Let me know where we are.

Tom

 
you are the expert thank God for you it works fine now.


Thank YOU
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top