468,765 Members | 803 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

Help with opening a report with only the selections

19
I need help with opening a report when a button is clicked, but I only want to open the report with the Object I have chosen in the combo box. This is what i have so far:

'If 2 is selected open the report with onlythe selected Vehicles'
ElseIf fraLabelTypeSelection = 2 Then
DoCmd.OpenReport "rptLabels", acViewPreview, , VehicleMake = Forms!frmLabelSelection!cboVehicle Else
MsgBox "Please make a Selection"
End If
End Sub

Report name = rptLabels
combo box where selections are made = cboVehicle
Form the combo box and option buttons are in = frmLabelSelection
i think the bold line is where I am going wrong - have I set it up incorrectly?
Nov 21 '06 #1
3 1339
MMcCarthy
14,534 Expert Mod 8TB
I need help with opening a report when a button is clicked, but I only want to open the report with the Object I have chosen in the combo box. This is what i have so far:

'If 2 is selected open the report with onlythe selected Vehicles'
ElseIf fraLabelTypeSelection = 2 Then
DoCmd.OpenReport "rptLabels", acViewPreview, , VehicleMake = Forms!frmLabelSelection!cboVehicle Else
MsgBox "Please make a Selection"
End If
End Sub

Report name = rptLabels
combo box where selections are made = cboVehicle
Form the combo box and option buttons are in = frmLabelSelection
i think the bold line is where I am going wrong - have I set it up incorrectly?
Hi Ducky

You haven't made a bad start, essentially in the criteria you have to put the field= in quotes and then & to join the value in the combobox to the statement. I've also surrounded the combobox value with single quotes because I'm assuming its text.

Expand|Select|Wrap|Line Numbers
  1.  
  2.   'If 2 is selected open the report with onlythe selected Vehicles'
  3.   ElseIf fraLabelTypeSelection = 2 Then
  4.     DoCmd.OpenReport "rptLabels", acViewPreview, , "[VehicleMake]='" & Forms!frmLabelSelection!cboVehicle & "'"
  5.   Else
  6.     MsgBox "Please make a Selection"
  7.   End If
  8. End Sub
  9.  
Mary
Nov 22 '06 #2
ducky
19
I have followed your instructions and it sort of works, I can select the item in the cobobox but when I click the PreviewLabel button, it opens the report with error in it. I think I might have mixed up my fields or forms but I don't know where I went wrong.
Nov 22 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
I have followed your instructions and it sort of works, I can select the item in the cobobox but when I click the PreviewLabel button, it opens the report with error in it. I think I might have mixed up my fields or forms but I don't know where I went wrong.
What is the SQL of the query behind the report?
Nov 22 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Steve Patrick | last post: by
2 posts views Thread by Craig B. | last post: by
1 post views Thread by prabhukalyan | last post: by
6 posts views Thread by Bob Alston | last post: by
5 posts views Thread by Debbiedo | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.