Benjamin Bolduc
Registered User.
- Local time
- Today, 08:59
- Joined
- Jan 4, 2002
- Messages
- 169
Hi there,
I don't know what I'm doing wrong. Pat Hartman gave me some great code to take a value from a listbox and apply to a where statment of a report. The code works fine untill I try to tweak with it a little.
Private Sub TheList_DblClick(Cancel As Integer)
Dim stWhere As String
Dim stWhere2 As String
Dim Switch As String
Switch = ChoiceList.Value
Select Case Switch
Case 1
stWhere2 = "[Supplier]=" & Me.TheList.Column(1)
DoCmd.OpenReport "Dueordersreport", acViewPreview, , stWhere
Case 2
stWhere = "[Transaction#]=" & Me.TheList.Column(0)
DoCmd.OpenReport "Dueordersreport", acViewPreview, , stWhere
End Select
End Sub
ok, now the second case works fine. (This is what Pat gave me).It only sends one record to the report because [Transaction#] is the primary key.
It's Case 1 that I'm having trouble with. (This is the one I tried to tweak myself). This one should send more than one value to the report, ( All records with similar Suppliers), but all it does is open the report with all of the records.
Do i need to take a different approach for case 1? or is it just a syntax error?
Any insight would be greatly appreciated.
Thanks!
Ben
I don't know what I'm doing wrong. Pat Hartman gave me some great code to take a value from a listbox and apply to a where statment of a report. The code works fine untill I try to tweak with it a little.
Private Sub TheList_DblClick(Cancel As Integer)
Dim stWhere As String
Dim stWhere2 As String
Dim Switch As String
Switch = ChoiceList.Value
Select Case Switch
Case 1
stWhere2 = "[Supplier]=" & Me.TheList.Column(1)
DoCmd.OpenReport "Dueordersreport", acViewPreview, , stWhere
Case 2
stWhere = "[Transaction#]=" & Me.TheList.Column(0)
DoCmd.OpenReport "Dueordersreport", acViewPreview, , stWhere
End Select
End Sub
ok, now the second case works fine. (This is what Pat gave me).It only sends one record to the report because [Transaction#] is the primary key.
It's Case 1 that I'm having trouble with. (This is the one I tried to tweak myself). This one should send more than one value to the report, ( All records with similar Suppliers), but all it does is open the report with all of the records.
Do i need to take a different approach for case 1? or is it just a syntax error?
Any insight would be greatly appreciated.
Thanks!
Ben