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

Selecting mutiple choices from either a list box to open a report

Status
Not open for further replies.

Poobear1929

Technical User
May 11, 2004
32
US
I am trying to open a report based on a selection from a list box on a form. I don't know if my code is way off or my query is is way off. Here is what I have so far, which is what I got from an old thread from last year regarding this problem.
my form is called ind_fit_test_report
my report is called fitness_individual
and my query is called fitness_individual
The list box is called Date

Private Sub Command9_Click()


Dim Repto As String
Dim frm As Form, ctl As Control
Dim varitem As Variant
Dim str As String

Set frm = Forms!ind_fit_test_report
Repto = "fitness_individual"
str = "[date]"
Set ctl = frm.Date
If ctl.ItemsSelected.Count = 0 Then
MsgBox "No date was selected," & (Chr(13)) & (Chr(13)) & "please select at least one date from list", vbExclamation, "selection Error"
Else
For Each varitem In ctl.ItemsSelected
str = str & ctl.ItemData(varitem) & ","
Next varitem
str = Left$(str, Len(str) - 2)
str = str & ")"
DoCmd.OpenReport Repto, acViewPreview, , str

End If
End Sub

here is my query
SELECT DISTINCT [Final Score].Test_ID, [Final Score].Member_ID, [Final Score].Last_name, [Final Score].First_name, [Final Score].Middle_In, [Final Score].Sex, [Final Score].Age, [Final Score].Date, [Final Score].Ab_circum, [Final Score].Crunchs, [Final Score].Run_Time, [Final Score].Push_ups, [Final Score].Bike_Test, [Final Score].[Total Score], [Final Score].[Fitness Level], Group_lookup.Group
FROM [Final Score], Group_lookup
WHERE ((([Final Score].Member_ID)=[Forms]![Ind_Fit_Test_Report]![Name_combo]) AND ((Group_lookup.Sex)=[FINAL SCORE]![Sex]) AND ((Group_lookup.Age_min)<=[FINAL SCORE]![Age]) AND ((Group_lookup.Age_max)>=[FINAL SCORE]![AGE]));

I am very new to Access, matter of fact this is my first. So I am really excited to learn.

Poobear1929
 
This appears to be VBA which has differences from VB 5.0 & 6.0 you might want to repost this in the

VBA Visual Basic for Applications (Microsoft)

Forums
 
pOObEAR

Ellaborate ur porblem in detail, u r not very clear, what reporting tool are u using, what is the os, ur vb version etc...

Gazal
 
Thank You Percent and Gazal, I am trying to write this code in VBA. Sorry, I guess I am in the wrong forum. I am new, so I am trying to learn how to use this website.

Poobear
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top