By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,928 Members | 1,200 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,928 IT Pros & Developers. It's quick & easy.

Help with opening a report with only the selections

P: 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
Share this Question
Share on Google+
3 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
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

P: 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
Expert Mod 10K+
P: 14,534
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.