473,473 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Combo Box Search Criteria

32 New Member
I have Combo box Titled ( Contract Status) Contains 4 values ( Active, Closed, Canceled, released)

I need when I chose form the Drop down list one of the status to run report with all contracts with that specific status.

All the Data are coming from one table contains 9 columns one of them are the ( Status)
Nov 8 '10 #1
20 2690
jimatqsi
1,271 Recognized Expert Top Contributor
Nebbie,
I assume you have a button to launch the report. In the click event of that button you will have code like this:

Expand|Select|Wrap|Line Numbers
  1. dim strCriteria as string
  2. dim strReportName as string
  3.  
  4. strcriteria = "[Status]='" & me!ContractStatus & "'"
  5. strReportName = "name of the report"
  6.  
  7. docmd.openreport strReportName , acPreview , strCriteria
  8. or
  9. docmd.openreport strReportName , acViewNormal
  10.  
That should do it.

Jim
Nov 8 '10 #2
nebula53
32 New Member
Unfortunately I tried it but it’s not working
Nov 9 '10 #3
colintis
255 Contributor
Have you correctly set up the report's control source?
Nov 9 '10 #4
nebula53
32 New Member
Private Sub Command141_Click()

Dim strCriteria As String
Dim strReportName As String

strCriteria = "[Status]='" & Me!ContractStatus & "'"
strReportName = "PMCONTRACTS"

DoCmd.OpenReport PMCONTRACTS, acViewNormal

End Sub

the error is ( 2465 : Microsoft office can't find the field ' ContractsStstus' referred to in your expression
Nov 9 '10 #5
colintis
255 Contributor
Check back and see what's your combo box actually named in the form. Or try use the Me.ContractStatus instead of Me!ContractStatus
Nov 9 '10 #6
semanticnotion
66 New Member
whats this problem is.....
i cant post my question.
Nov 9 '10 #7
semanticnotion
66 New Member
sorry for reply here
but what this problem tells when i post my question "The message you have entered is too short. Please lengthen your message to at least 1"

i cant post my question even cant edit the above reply. its a test post.
Nov 9 '10 #8
nebula53
32 New Member
The Combo box name is correct, when I changed the Me! To ME.
I received this Error message (Method or Data member not found)
Nov 9 '10 #9
mshmyob
904 Recognized Expert Contributor
Use the little reply button on the message - not the normal reply button. For some reason using the normal reply button doesn't work.
Nov 9 '10 #10
colintis
255 Contributor
Have you tried using this one?
Expand|Select|Wrap|Line Numbers
  1. docmd.openreport strReportName , acPreview , strCriteria
As I see it should be somewhere typed incorrect but not the code you posted.
Nov 12 '10 #11
jimatqsi
1,271 Recognized Expert Top Contributor
Did you copy and paste this error message, or retype it?
the error is ( 2465 : Microsoft office can't find the field ' ContractsStstus' referred to in your expression

I ask, because I see the spelling of the object name is different in the error message from what you said it was.
One is ContractsStstus, with status spelled incorrectly, the other is spelled correctly. Maybe you've just got a typo.

Jim
Nov 16 '10 #12
nebula53
32 New Member
Jim there where Typo error when I copied the message.
Nov 21 '10 #13
nebula53
32 New Member
Please find the attached to understand the concept
Attached Files
File Type: zip TEST.zip (60.5 KB, 89 views)
Nov 21 '10 #14
mshmyob
904 Recognized Expert Contributor
Very sloppy programming practices. The message is simple: Access cannot find a field or control named "ContractStatus". Simply because it does not exist. Your control name is [Contract Status] - with a space. You therefore need to wrap the control name or field name in square brackets.

Making a few minor changes to Jimatqsi code you should have:

Expand|Select|Wrap|Line Numbers
  1. Dim strCriteria As String
  2. Dim strReportName As String
  3.  
  4. strCriteria = "[Contract Status]='" & Me![Contract Status] & "'"
  5. strReportName = "PMCONTRACTS"
  6.  
  7. DoCmd.OpenReport strReportName, acPreview, , strCriteria
  8.  
Note:
1. The wrapping of the control name in square brackets to take into account the bad habit of using spaces.
2. Changing [Status]= to [Contract Status]= since there is no Status control or field in your report.
3. I added an extra comma in the openreport line since strCriteria is a SQL expression not a filter name.


cheers,
Nov 21 '10 #15
nebula53
32 New Member
mshmyob

thank you for your help I really appreciate it
Nov 22 '10 #16
nebula53
32 New Member
There is one thing I need to add

I need to set the Combo box to (Select) as default and If I didn’t chose any of the other criteria ( Active, inactive) then the report should show all of the information in the table



Expand|Select|Wrap|Line Numbers
  1. Dim strCriteria As String
  2. Dim strReportName As String
  3.  
  4. strCriteria = "[Contract Status]='" & Me![Contract Status] & "'"
  5. strReportName = "PMCONTRACTS"
  6.  
  7. DoCmd.OpenReport strReportName, acPreview, , strCriteria
  8.  
  9. ' Reset Form
  10. [Contract Status] = "SELECT"
Nov 22 '10 #17
colintis
255 Contributor
For setting defaults, apply the value of the combo box to the form_load event, which it will set the [Contract Status] to "SELECT" when the form is open initially.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3.     [Contract Status].value = "SELECT" 
  4.  
  5. End Sub
  6.  
Then in your button click event we have earlier, simply place a if else statement to open the report in specific line.
Expand|Select|Wrap|Line Numbers
  1. Dim strCriteria As String 
  2. Dim strReportName As String 
  3.  
  4. strCriteria = "[Contract Status]='" & Me![Contract Status] & "'" 
  5. strReportName = "PMCONTRACTS" 
  6.  
  7. If [Contract Status].Value = "SELECT" Then
  8.     DoCmd.OpenReport strReportName, acPreview
  9. Else
  10.     DoCmd.OpenReport strReportName, acPreview, , strCriteria 
  11.  
Nov 22 '10 #18
NeoPa
32,556 Recognized Expert Moderator MVP
To set the default of a form control use the .DefaultValue property. Setting the .Value property has quite a different effect. It works for only the first record and it dirties the buffer.
Nov 22 '10 #19
nebula53
32 New Member
colintis

I appreciate your help its working fine. Thanks
Nov 23 '10 #20
nebula53
32 New Member
NeoPa
Thank you for the explanation, its helps to understand more.
Nov 23 '10 #21

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

Similar topics

1
by: TH | last post by:
I am (still :) working on a recipe database. Now I am trying to figure out how to set it up for an ingredient search. What I want it to be able to do is three things: 1. Search based on just...
1
by: Casey | last post by:
Hi, How would one allow for possible multiple search criteria using FREETEXTTABLE. For example, my table "listings" has a full-text search catalog, and I may want to: SELECT * FROM listings...
1
by: James890 | last post by:
I want to enable a user to enter a start and end date to define the period they want to search for records of members who joined on certain dates. Funny thing is...I've got it to work half of the...
3
by: AishaKhalfan | last post by:
Hi, :wave: I have many search criteria in my program, such as: search by name, search by age, search by gender, search by city the user can search by name only, or by name and age, or by...
4
by: torontolancer | last post by:
Hi there how r u .I would really appriciate ur concern regarding checking out this code. its beind a command button and i am have a combo box selecing a query criteria and then pressing the button...
0
by: Samita | last post by:
Hi , I am doing a search criteria for employee where i want to search employee by allotment year in a text box, that too by entering the last 2 digits of year in the text box. what is the logic...
1
by: Samita | last post by:
I want to do an employee search in an employeemaster page with email id as the search criteria in vb.net.How to achive that,any email validation is needed while searching?
5
by: LC2007 | last post by:
Hello, Can someone please help me on how to create Search Criteria form, i can't find exactly what i am looking for!!! i need a search button! but i can't find anything that can help me!
7
by: veliscorin | last post by:
hi experts, the topic is rather misleading but i couldn't find a better way to phrase it.. here's my scenario: Table A: Products Table B: Attributes (with a product_id to show which product it...
4
by: sanika1507 | last post by:
Can you help me out please ! This is a search Stored procedure that returns the list .of patients .i want to include the start and end date in the search criteria So you will need to accept the...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.