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)
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: - dim strCriteria as string
-
dim strReportName as string
-
-
strcriteria = "[Status]='" & me!ContractStatus & "'"
-
strReportName = "name of the report"
-
-
docmd.openreport strReportName , acPreview , strCriteria
-
or
-
docmd.openreport strReportName , acViewNormal
-
That should do it.
Jim
Unfortunately I tried it but it’s not working
Have you correctly set up the report's control source?
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
Check back and see what's your combo box actually named in the form. Or try use the Me.ContractStatus instead of Me!ContractStatus
whats this problem is.....
i cant post my question.
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.
The Combo box name is correct, when I changed the Me! To ME.
I received this Error message (Method or Data member not found)
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.
Have you tried using this one? - docmd.openreport strReportName , acPreview , strCriteria
As I see it should be somewhere typed incorrect but not the code you posted.
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
Jim there where Typo error when I copied the message.
Please find the attached to understand the concept
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: -
Dim strCriteria As String
-
Dim strReportName As String
-
-
strCriteria = "[Contract Status]='" & Me![Contract Status] & "'"
-
strReportName = "PMCONTRACTS"
-
-
DoCmd.OpenReport strReportName, acPreview, , strCriteria
-
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,
mshmyob
thank you for your help I really appreciate it
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 - Dim strCriteria As String
-
Dim strReportName As String
-
-
strCriteria = "[Contract Status]='" & Me![Contract Status] & "'"
-
strReportName = "PMCONTRACTS"
-
-
DoCmd.OpenReport strReportName, acPreview, , strCriteria
-
-
' Reset Form
-
[Contract Status] = "SELECT"
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. - Private Sub Form_Load()
-
-
[Contract Status].value = "SELECT"
-
-
End Sub
-
Then in your button click event we have earlier, simply place a if else statement to open the report in specific line. -
Dim strCriteria As String
-
Dim strReportName As String
-
-
strCriteria = "[Contract Status]='" & Me![Contract Status] & "'"
-
strReportName = "PMCONTRACTS"
-
-
If [Contract Status].Value = "SELECT" Then
-
DoCmd.OpenReport strReportName, acPreview
-
Else
-
DoCmd.OpenReport strReportName, acPreview, , strCriteria
-
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.
colintis
I appreciate your help its working fine. Thanks
NeoPa
Thank you for the explanation, its helps to understand more.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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?
|
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!
|
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...
|
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...
|
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,...
| |
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...
|
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,...
|
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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |