473,796 Members | 2,621 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create report with Combo boxes selections?

46 New Member
Question: How do I create a Report based off the values/selections of mutliple combo boxes in a form?

I have tried this several times with several failures and have used multiple
codes to try this and each has been unsuccesful.

I will try to explain my database and its contents
Tabels and Fields ((PK) indicates the primary Key):
tblAssets: ID(PK), AssetNumber, SerialNumber, ModelName, ComputerName,
DeploymentDate, Active, UserName, OfficeName,OSNa me
tblContacts: ID, Company, LastName, FirstName, Initial, EMailAddress,
JobTitle, BusinessPhone, Address, City, State, Zip, Country, Username(PK)
ChargeCode, LocationCode
tblLocation: LocationCode(PK )

tblModel: ModelID(PK), ModelName

tblOfficeVersio n: OfficeID(PK), OfficeName

tblOSVersion: OSName(PK)

So initial i have tried to create a form with two combo boxes. cboModel and
cboLocation and with a cmdbutton that open rptModel. Upon opening I want to
see how many of each model is at each location.

Exaple: Location: OH01
Model: Dell 630 = 20
IBM M50 = 15

I have tried multiple codes with no success. Please help I have been posting
this problem for 3 weeks with very little help. Not that people have tried
but it seems that this is an issue that isnt covered very often. Thank you
for any help and if there are any questions please ask. I can also provide a
code if that helps, but like I said I have tried various differant codes with
no success.Thanks!
Mar 2 '09
30 2628
vanlanjl
46 New Member
that should be all that comes in the cboLocation combo box
Mar 2 '09 #21
OldBirdman
675 Contributor
1) I'm happy you can run this SELECT statement in the query design window. This is an important Tool for you to use.
2) Wrong Answer. Your answer in 3) says you are not getting the results you want. So the answer to 2) is NO, it is NOT what is wanted in this cbo.
3) You are ahead of yourself again. You are NOT trying to do your report yet. You are trying to get the form right that will allow selection of specified models at specified locations.
4) Until you forget the report query, and get the form controls working, you are not going to get either done.

You have a form with 2 comboboxes, cboModels and cboLocations. This form MUST be able to show a Model in the text portion of cboModels and a Location in the text portion of cboLocations. To do so, you must have a list of Locations in the list portion of cboLocations, so you can choose one.

I think cboModels works, but cboLocations doesn't. You need to work with a table that has the information you want. You are going to SELECT...FROM this table. This is the table that should be used in your query design. Now, what field or fields do you need. In other words, SELECT What? This field(s) should be in the table on your query design. Drag the field to the design grid (in Design View). Change to DataSheet View. This should be what you want. Add a sort in the "Sort:" row of the design grid. This should be the source for your cbo.
Mar 2 '09 #22
vanlanjl
46 New Member
In response to #22 refer to #20
This is right right?
Mar 2 '09 #23
OldBirdman
675 Contributor
Very Good!

Lets finish cboLocations. Don't rely on the order being correct. Add the sort to the design grid, which will add an ORDER BY to the SQL statement. Please notice that by using the Query Design Tools, you can add features and check results until your results are correct.

Now, we are going to work on the query for the report. Forget the form for now, and the report too. Until we get the query correct, we are not going to attempt to use the cbo values from the form.

What table(s) contain the fields you want. Can you, in the Query Design, display all those fields. Notice you are not counting yet. Just listing the fields and their values. This is step 1.
Mar 2 '09 #24
vanlanjl
46 New Member
Holy mother of God!
Okay I inserted the following select statement int cboModels:
Expand|Select|Wrap|Line Numbers
  1. SELECT [tblModel].[ModelName], [tblModel].[ModelName] FROM tblModel ORDER BY [ModelName]; 
  2.  
and into cboLocation:
Expand|Select|Wrap|Line Numbers
  1. SELECT [tblLocation].[LocationCode] FROM tblLocation ORDER BY [tblLocation].[LocationCode];
  2.  
and it works except for one thing. It still has a pop up window "Enter Parameter values" form and asks for the model. I entered "D630"
and pushed enter and the report was created properaly.
Why is that pop up form coming up and how do i get rid of it?
And thank you so much so far!!!!
Mar 2 '09 #25
OldBirdman
675 Contributor
it works except for one thing. It still has a pop up window "Enter Parameter values" form and asks for the model. I entered "D630"
and pushed enter and the report was created properaly.
Why is that pop up form coming up and how do i get rid of it?
And thank you so much so far!!!!
Post the SQL as you have it for this try
Mar 2 '09 #26
vanlanjl
46 New Member
i did in message #25
cmdbutton
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub Command7_Click()
  4. strWhere = "1=1 "
  5. If Not IsNull(Me.cboModel) Then
  6.   strWhere = strWhere & " AND [Model] =""" & Me.cboModel & """ "
  7. End If
  8. If Not IsNull(Me.cboLocationCode) Then
  9.   strWhere = strWhere & " AND [LocationCode] =""" & Me.cboLocationCode & """ "
  10. End If
  11.  
  12. DoCmd.OpenReport "tblContacts", acPreview, , strWhere
  13. End Sub
  14.  
I am geting an error in the last line of code:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "tblContacts", acPreview, , strWhere
  2.  
strWhere ="1=1 AND [Model]="630" And [LocationCode] ="OH01" "
Mar 2 '09 #27
OldBirdman
675 Contributor
Expand|Select|Wrap|Line Numbers
  1.   strWhere = strWhere & " AND [Model] =""" & Me.cboModel & """ " 
  2.  
Have you got a field called [Model]?
Mar 2 '09 #28
vanlanjl
46 New Member
Duh! I should have changed that a long time ago its should be [ModelName]

And it works.

You are awesome!! Thank you for spending the time with me to figure this out!!
Mar 2 '09 #29
OldBirdman
675 Contributor
You're welcome
I hope you learned something. That was what this exercise was about.
Mar 2 '09 #30

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

Similar topics

4
1541
by: Steve Chatham | last post by:
I have a page where I have some combo boxes on it. A click on each one spawns another box, and another until each area has been selected, or until they choose to pull all items into a datagrid from that category. For instance: say the first combo has in it: meat dairy
3
1507
by: ducky | last post by:
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...
4
2362
by: Dave | last post by:
I wasn't sure how to search for previous posts about this, it felt real specific. Ok so here's the database & problem: I have 4 combo boxes: cboServer, cboPolicy, cboDB, and cboApplication. The idea behind the database is for a user to search/ select desired information in any kind of combination between the 4 combo boxes. Then the user clicks a button (btnSearch) and subsequently a query ("Search Function") is run that shows all 4...
6
3684
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
1
2909
by: Dave | last post by:
Hello all, First I'd like to apologize...This post was meant to be put in my previous post, but I tried many times without success to reply within my previous post. Now here goes... I have a main form (RD Form) with 4 combo boxes (i.e. cbo1, cbo2, etc) and a subdatasheet (the subform...let's call it subInfo) below the combo boxes on the RD Form. I hope this eliminates any confusion of the
6
9431
by: Dave | last post by:
On my form I have combo boxes. These combo boxes, after updating them, populate respective listboxes that are located below the combo boxes on the same form. I am trying to use a "generate report" button located on my form to print all of the list box values (that have been updated via selection from combo boxes) from the form to the report. I've tried using a macro with the code: Macro Name: cmdGenerateReport : On Click Action:...
2
4620
by: SHAWTY721 | last post by:
I have a form that contains two combo boxes that are related to each other. I need to find a way to populate my text box based on the criteria of the two combo boxes so the appropriate number appears in the text box.
4
8983
kcdoell
by: kcdoell | last post by:
Hello: What is the best way to stop a report from running if the query is empty? Currently, I have a form that has a command button on it. The user has to make selections from 3 combo boxes on the form and then via the cmdbutton the report opens in preview mode. I want to stop it from executing if the query is empty. I thought I could do this by checking the record count by the following code but I error out with the following message: ...
12
4049
by: micarl | last post by:
How would i print a report based on criteria selected from several Combo Boxes as well as multiple Multi Select List Boxes, that are located on the same form? I can get one Multi List Box, just not several, to report using this code i found - Private Sub cmdPreview_Click()
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10237
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10018
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.