Pass to Query

D

Denver

Hi,

I have a list box(List1) that displays all my weekly report with this
codes.....

SELECT [Name] FROM MSysObjects WHERE [Type]=1 AND [Name] LIKE
"*exception06W*" ORDER BY [Name];

i have a command button REPORT (Command0)..

i want that when i click to Command0 it will generate reports.
i have already a query for all the calculations for my weekly report.
i just want that whatever i selected from my List1 it will pass to that
query and reports. so that there is no need for me to do copy, paste and
rename..

hope someonse is kind to help me on how i can start my code for my Command0...
if you can give me a link for a dowload sample is better, too.

thanks
 
D

Denver

thanks for your kind and immediate response i appreciate it...

i will be coming back to you if i meet errors...

but any thank you..

denver



MGFoster said:
Denver said:
Hi,

I have a list box(List1) that displays all my weekly report with this
codes.....

SELECT [Name] FROM MSysObjects WHERE [Type]=1 AND [Name] LIKE
"*exception06W*" ORDER BY [Name];

i have a command button REPORT (Command0)..

i want that when i click to Command0 it will generate reports.
i have already a query for all the calculations for my weekly report.
i just want that whatever i selected from my List1 it will pass to that
query and reports. so that there is no need for me to do copy, paste and
rename..

hope someonse is kind to help me on how i can start my code for my Command0...
if you can give me a link for a dowload sample is better, too.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You will have to have a VBA routine to iterate thru the report names
selected in the ListBox. Like this:

Private Sub Command0_Click()

' This routine depends on the ListBox property "Multi Select" being
' set to "Extended."

Dim lst As ListBox, varItm As Variant

' set up a reference to the ListBox
Set lst = Me!List1

' For this to work the ListBox column holding the report name
' must be the Bound Column.
For Each varItm In lst.ItemsSelected
DoCmd.OpenReport lst.ItemData(varItm)

' You may want to put a Pause routine here if rpts pile up.

Next

End Sub

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSQEPB4echKqOuFEgEQIVHACfVvdjz86UwsBg55zPmWf+5+q5gf8AoIiZ
yuEwnNb6sR5JbL72WRFJ2CAZ
=zbsd
-----END PGP SIGNATURE-----
 
D

Denver

hello again MGFoster,

i have this code now but i have this errors that i cannot fix it by myself..
Run-time Error '2480': You entered to a property by a numeric argument that
isnt one of the property number in the collection...

can you help me what this error is and how i can fix it?
or maybe i miss some code? hoping you're kind uderstanding because
im not a programmer and new in VBA...

i did not change Multi Select to Extended or Simple, does this affects the
code?
do i need to write IF Then Statement and Column.Count? how?
on your last response you said 'For this to work the ListBox column holding
the report name must be the Bound Column., what is it about?

here is my code with the Run-time error '2480'....

On Error GoTo Err_Command3_Click

Dim lst As ListBox, varItm As Variant

Set lst = Me!List1

For Each varItm In lst.ItemsSelected
DoCmd.OpenReport lst.ItemsSelected(varItm)

Next

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click


thanks anyway MGFoster...

*********************************************************
Denver said:
thanks for your kind and immediate response i appreciate it...

i will be coming back to you if i meet errors...

but any thank you..

denver



MGFoster said:
Denver said:
Hi,

I have a list box(List1) that displays all my weekly report with this
codes.....

SELECT [Name] FROM MSysObjects WHERE [Type]=1 AND [Name] LIKE
"*exception06W*" ORDER BY [Name];

i have a command button REPORT (Command0)..

i want that when i click to Command0 it will generate reports.
i have already a query for all the calculations for my weekly report.
i just want that whatever i selected from my List1 it will pass to that
query and reports. so that there is no need for me to do copy, paste and
rename..

hope someonse is kind to help me on how i can start my code for my Command0...
if you can give me a link for a dowload sample is better, too.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You will have to have a VBA routine to iterate thru the report names
selected in the ListBox. Like this:

Private Sub Command0_Click()

' This routine depends on the ListBox property "Multi Select" being
' set to "Extended."

Dim lst As ListBox, varItm As Variant

' set up a reference to the ListBox
Set lst = Me!List1

' For this to work the ListBox column holding the report name
' must be the Bound Column.
For Each varItm In lst.ItemsSelected
DoCmd.OpenReport lst.ItemData(varItm)

' You may want to put a Pause routine here if rpts pile up.

Next

End Sub

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSQEPB4echKqOuFEgEQIVHACfVvdjz86UwsBg55zPmWf+5+q5gf8AoIiZ
yuEwnNb6sR5JbL72WRFJ2CAZ
=zbsd
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top