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!

LIST BOX

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
In forms, i have a list box where i move the items selecteds in other list box.Now i want to move the second list box content in a report without a query.

Thanks a lot

P.S. Sorry for my english
 
Use you second list box's selected content as a filter for the report:

DoCmd.OpenReport "{report-name}",,,,"{condition}"

e.g.

DoCmd.OpenReport "Monthly Sales", , , , "SalesID = " & me!List2

There are two ways to argue with a woman - neither one works.
Another free Access forum:
More Access stuff at
 
Thank's a lot for your support

I know what you mean but i dont know where do i put the code. i had try it in the "Private Sub openreport" and a error message that wont found a List2.I open the report from a form.

I am a newbie and your help is so great for me.

Thank's
 
The code to actually open your report should probably originate in the form that has the two list boxes, specfically in the "after update" event of the second listbox. Make sure as well, that you don't CLOSE the form before you call the report, because the report won't know what's in the list box anymore...

Something like this is probably what you want:

Sub ListBox2_AfterUpdate
Me.Visible = FALSE
DoCmd.OpenReport "Monthly Sales", , , , "SalesID = " & me!ListBox2
End Sub

The beauty of the .VISIBLE = FALSE guy is that the form's info is still available to the report, even though the form is invisible. Then, on your Report's CLOSE event, make the form visible again:

Sub Report_Close()
Forms!MyFormName.Visible = True
End Sub

You need to code the specific form name in the report-close event. While IN the form, "ME" can refer to the form.











There are two ways to argue with a woman - neither one works.
Another free Access forum:
More Access stuff at
 
I maked that you wrote and my listbox in my report is always
empty. do you know why?

thank's
 
It's hard to tell exactly. If you can, why don't you ship a copy to me and I'll take a quick look. I will be around until about noon Eastern time in the US...

My email can be found at my site, see my sig line.

Jim There are two ways to argue with a woman - neither one works.
Another free Access forum:
More Access stuff at
 
I tried to send you a copy but I can't because it's too big.
That what i want, it's to transfer the content of the form listbox to the report listbox whitout a query.

Thank's for your support
 
MVX - cut and paste the code from your 2nd listbox here and I or someone else will take a look at it.

I will be available until apx 5PM Eastern Daylight Time. Then I have to go teach an Access class.. [bigsmile]

Jim
There are two ways to argue with a woman - neither one works.
Another free Access forum:
More Access stuff at
 
Hi Jim

First, in form, I have a command button who transfer the items selecteds in a listbox to another listbox the code is:

Private Sub Commande206_Click()
CopieSelected Me



End Sub

Function CopieSelected(frm As Form) As Integer

Dim Liste72 As Control
Dim Liste204 As Control
Dim chObjets As String
Dim entLigneEnCours As Integer
Set Liste72 = frm!Liste72
Set Liste204 = frm!Liste204

For entLigneEnCours = 0 To Liste72.ListCount - 1
If Liste72.Selected(entLigneEnCours) Then
chObjets = chObjets & Liste72.Column(1, entLigneEnCours) & ";"
End If

Next entLigneEnCours

Liste204.RowSource = ""
Liste204.RowSource = chObjets

End Function

In my second listbox in a form, I have this code:

Private Sub Liste204_AfterUpdate()
Me.Visible = False
DoCmd.OpenReport "Réservation", , , , "Liste38 =" & Me!Liste204
End Sub

In my report, I have a listbox"Liste38" indépendent and I want that the results of form listbox"Liste204" appear in.

Thank's for all
 
OK, one problem here is that the "ME" in
DoCmd.OpenReport "Réservation", , , , "Liste38 =" & Me!Liste204

refers to the current object, which in this case is the REPORT, not the form you just made invisible.

DoCmd.OpenReport "Réservation", , , , "Liste38 =" & forms!{your-form-name}!Liste204

I'm just a little confused though, why do you have A LISTBOX on a report?

Is it just that you want the contents of the listbox from the form DISPLAYED on the report like a label?

That is simple to do with a text box that points back to the listbox:

=Forms!{your-form-name}!Liste204

and then you don't need anything after the

DoCmd.OpenReport "Réservation"

Jim

There are two ways to argue with a woman - neither one works.
Another free Access forum:
More Access stuff at
 
Hi Jim
Thank's to be patient whit me

I tried that you wrote and it didn't work...Maybe that the "Liste38" properties in the report is wrong...

Second, I'm be able to transfer a text box in the form to the text box in the report but it didn't work when I want to transfer all content of listbox to a text box whit a rowsource =Form!My Form!Liste204. It's always write "?nom" in the box.

Thank's

Michel
 
Ok, Michel, I think we are getting closer here. If your List box #2 is a "multi-select" list box, the only way to get ALL the selected rows into a text box is to do a loop similar to what you used to get the selected items in List box #1 over to List box #2. You should be able to construct a string variable just like you did, and pass it to the report for display.

PS - Don't trouble yourself about my patience - believe me, your English is a lot better than my French! Parlez vou?... There are two ways to argue with a woman - neither one works.
Another free Access forum:
More Access stuff at
 
Jim, my second listbox is not "multi select".It is the transfer of listbox1 itemselected. I dont need to make a selection in a listbox2. Do you think that the loop can be work anyway?

Thank' for all

Michel
 
You know, that might be the problem here - since there's no "selection" made from the 2nd listbox, a reference to it doesn't return any value.

You know? A list box might have 10 items in it's SOURCE, but until you click on one, there's no value in the "Me.LISTBOX2" control..

Are we getting closer?
There are two ways to argue with a woman - neither one works.
Another free Access forum:
More Access stuff at
 
Hi Jim,

The Listbox2 in a form is not important, I could be delete it.So what procedure must one follow to past the listbox1 items selected to my report. If is whit a command button, how do I modify my code? I will try to do all that we have exchange in this thread (To the listbox1).

Thank's

Michel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top