Query/sql Criteria Help Using Forms

Sep 22, 2005

I am trying to create a query to be used by a report where the criteria are based on certain controls in a form.

EG ‘forms![FormName]![Control]’

As the fields are date fields, I am using 2 controls in the form and the ‘Between’ operator to choose a ‘From’ and ‘To’ date to search.

EG ‘between forms![FormName]![Control1]) and forms![FormName]![Control2]’

Not all of the records in the various date fields have dates in them, some are just null.

I wanted the query to look at the form and see that if the date controls in the form were blank (or null) then show all records for that field in the query. If the controls in the form have dates in them, then just filter the records in the query that meet that critera. (i.e. the dates in the control.)

The problem is I can’t find a way to do it!

I tried this in the query criteria for a particular date field:

Between [Forms]![Frm_Returns]![ReturnsFrom] And Forms]![Frm_Returns]![ReturnsTo] Or Not Like "*" Or Not Like IIf(IsNull([Forms]![Frm_Returns]![ReturnsFrom]),"!","*")

That seems to work for just one of the date fields, but I have 8 date fields in the query and 8 controls in the form that I need to enter criteria in a similar way. When I try doing this on more then 1 field, it just doesn’t work!

Can anyone help please?

View Replies


ADVERTISEMENT

Forms :: Query Criteria Used For Same Subform In Multiple Parent Forms

Apr 11, 2014

I have a sub form that shows me a companies history. This subform is used on 2 different Parent forms. The record source for the sub form uses a criteria that looks at a companyID field on the parent to determine which records to return. My question is how do I have the query criteria depend on which form is currently opened? The criteria would look something like this:

[Forms]![frmCompanyHistory]![txtCompanyID] OR [Forms]![frmCompany_Project_Details]![txtCompanyID]

If I open the form with this criteria, I will be asked for a value in txtcompanyID for whatever parent form is not open. How do I properly do this without making multiple queries that are almost identical?

View 5 Replies View Related

Forms :: Toggle On Form To Query Between Two Criteria?

Aug 21, 2013

I am attempting to create a toggle on a form that would instruct a query which criteria to use.

Specifically they are date criteria. I want to be able to toggle between evaluating on a start basis verse a ship basis.

If the toggle is set to 'Start Date', the query would use the start date as its criteria. If the toggle is set to 'Ship Date" it would use the ship date.

The other complication is that within the query, "Start Date" and "Ship Date" are two separate fields always contained in the query, so how do I write the query so that it only applies criteria to the appropriate field based on the toggle setting?

View 6 Replies View Related

Forms :: Field Not Being Passed To Query As Criteria?

Apr 18, 2013

Instead of the combo box value being passed into the target query as it should I *always* receive a popup that states "Enter Parameter Value"

I set my filter criteria as such in the target query: "[Forms]![Invoice_Form]![comboFamily]" but for some reason, despite there being a value in that combo box, I am always prompted for a parameter. VBA code associated with a "Generate Invoice" button on the form causes the query and the report to open.

I've attached the database, everything is dummy data.

The suspect form is the "Invoice_Form" the suspect query is the "Invoice_Query" and the suspect report is the "Invoice".

If a number is entered in the "Enter Parameter Value" field that matches the primary key of a family in the "Family" table then a report is generated correctly (as it is currently configured). For some reason it seems that the form with the combo box just cannot be accessed by the query.

View 4 Replies View Related

Forms :: ListBox As Search Criteria In Query

Jan 28, 2014

I have a search form that uses several comboboxes, textboxes and checkboxes that are used as criteria in a query. You enter in the relevant information, hit search and a report opens based on the filtered query.

What I would like to do is change one of these combo boxes to a listbox and use the multiple selection as the query criteria. I know it's not as simple as just putting the listbox as a criteria in the query, and I've also tried many different variations on the varItem and strWhere code.

View 14 Replies View Related

Forms :: Passing Check Box Value To A Query As Criteria

Jan 30, 2014

I need to pass values of my two check boxes on my Form

Check box US and Check Box Canada
if both checked the criteria would be "UD", "ud',"b","B","us","US","CD","cd"
if Canada check box checked criteria would be "cd","CD"
if US only checked criteria would be UD", "ud',"b","B","us","US"

how to write the criteria statement on the query?this probably would be a complicated iff statement?

View 2 Replies View Related

Forms :: DLookup Without Criteria - Getting Value From Query Expression

Mar 23, 2014

I've never used DLookup before and I can't get it to work for me so far.

I have 1 table which contains products and different properties of each product, such as the weight of the product.

I have created a query which sums the weight of all products, but only for those that have a value >0 in a certain field. This all works fine.

Now I simply want to display that calculated total weight in a text box on a form. So I thought DLookup could be used for that. But I can't get it to work, maybe because I'm not putting in any criteria? In the control source of the text box
I've put the following:

=dlookup("[TotalWeight]","qryTotals")

I don't have any criteria, I just want the value from my qry expression. The textbox on my form now displays #name?

View 3 Replies View Related

Forms :: Can Use Main Form As Query Criteria

Mar 10, 2014

I am working on a warehouse database and i have run into a small problem. I am using access 2010 and 2007 depending on location.

I have attached a picture of my database relation ship so you can see where i am coming from. What I am trying to do is make a main form called products and use that as the sours of the information that my queries look for and then have linked pages to my main form showing the results of that.

Example of the above would be as follows

Product on main form lets say tennis ball red then on my link forms show stock plus location and quantity

On another linked form product on main form and orders for that product and qty

View 3 Replies View Related

Forms :: Pulling Query Criteria From Form

Apr 25, 2014

I have several (about 10-15) queries that I have designed to run monthly reports. Various pieces of the criteria for each query need to change regularly. For example, in design view, I currently have a 'Where' field for each of our eight products. Where 1= include the product in the query analysis. Where 0= do not include the product in the query analysis. We would like to have a form that has entry boxes for each product where the person doing the analysis could type '1' or '0' and then the query could update the criteria entered before running.

We also need dates to update via the form. I currently have [Current Period End Date] and [Prior Period End Date] pop up boxes on each query that allow the person running them to enter their desired dates. But again, my boss wants to limit their involvement with the actual queries. Plus, you end up entering the dates for all 10-15 queries, which is a hassle. We would like to have entry boxes for the desired dates in the form and have the queries pull date criteria from the form.

If we can pull query criteria directly from a form, is it possible to create a table from a form and then pull the query criteria from the table?

View 2 Replies View Related

Forms :: Criteria To Query From Form - Option Group?

Feb 2, 2014

I have a query that i need to run from a form. From form I need to pass criteria

1 for canada
2 for us
1 and 2 for us and Canada

The criteria needs to go into field Pricing Type. If user selects 1 then only Pricing Type 1 will display. If user selects 2 than only Pricing Type 2 should display. I user selects both , Pricing Type 1 and 2 should be listed.

Can this be achieved with option group?

View 2 Replies View Related

Forms :: Use Form To Get Criteria For Query To Create Report

Apr 1, 2013

I want to create a form that allows a user to enter criteria that will be passed to an existing make table query. suggestions on a user friendly book on Access 2010 programming, I'd be really interested. I'd like to be able to do more with Access 2010.

View 3 Replies View Related

Forms :: Pulling Data From A Query Based On Criteria

Apr 13, 2013

I am having a problem pulling some data from a query to populate text boxes in a form

Text27 = DLookup("'SumOfSumOfDocCount'", "SumTotalPerf", "DateReceived=" & Forms.Tracker.Text23.Value & "AND 'BookedInID'=" & Forms.Tracker.BookedInID.Value)

I am trying to pull the sum of document count from the SumTotalPerf query where the datereceived in the query matches the date on the form and the BookedInID in the query matches the BookedInID on the form, at the moment Text27 just displays as blank with no error messages displayed so I am lost as to what im doing wrong, Ive double checked all the spelling for my column names etc and all is correct.

View 8 Replies View Related

Forms :: Update Query Not Pulling Criteria From Form

Jul 17, 2013

I'm trying to update a record in a table, from a query that is run as part of an event from a command button on a form.

I have a table called 'Assets', a table called 'Disposals', and a form called 'Disposal Entry'. I would like the user to select an Asset ID from a combobox on the form, then when the button is clicked it adds a record to the 'Disposals' table, and updates the Status for that specific Asset in the 'Assets' table to "Disposed".

It adds to the Disposal table fine, but I can't get it to update the Asset table.

My query looks like:
Field: Status Asset ID
Table: Assets Assets
Update To: "Disposed"
Criteria: [Forms]![Disposals Entry]![Asset ID]

I've checked the spelling and everything looks ok.

The [Asset ID] control on the form is bound to the Assets table. If I edit the control and clear out what is in Control Source, then it updates the table and works fine.

However, I want to keep it bound as I have a subform on my home page showing the latest disposals.

How I can get the query to use the Asset ID on the form as the Criteria?

View 14 Replies View Related

Forms :: Criteria In Query Does Not Work With Navigation Form

Oct 23, 2014

how the Forms work I am trying to put some of them in Navigation Form and my commands does not work as they did in Form."Home app" is the navigation form, "Apeluri_neinchise" is the subform of "Home app" and "Combo1" is the criteria based on which a query shows a specific data.

What is the proper formula for query criteria?

[Forms]![Home app]![Apeluri_neinchise].[Form]![Combo1] (I tried this but it's not workink)

View 3 Replies View Related

Forms :: Passing Operator Values To Criteria Field In Query

Mar 11, 2014

I have a query which contains figures. i have a search form based on this query and need to search using comparison operators such as <10000 or >500.

Is there a way to pass these value to criteria field in query ?

View 14 Replies View Related

Forms :: Passing Criteria To Query From Option Group Control

Feb 2, 2014

I need to pass a criteria to a query from my option group control to my query.

It contains three options 1,2 and 3.

If option 3 then Pricing Type 1 and 2

How do I make the code below working?

IIf([Forms]![FrmUserSelection]![PricingType] Like 3,([dbo_AGPricingDiscounts].[PricingType])="2" Or ([dbo_AGPricingDiscounts].[PricingType])="1",",[Forms]![FrmUserSelection]![PricingType]")

View 3 Replies View Related

Forms :: Running A Query Based On User Selection Criteria On Form

Jan 9, 2014

I have a form which lets the user enter a contract ID and then a combo box that has a list of reports which run against whichever ID is entered.

What I want to know if I put the ID's in a table if theres a way to allow the user to select multiple ID's in one go and run the report against them the range rather than 1 at time?

I'm thinking about utilising the check/tick boxes would this be possible? or another way?

I'm using 2003 and have some VBA ability.

View 5 Replies View Related

Forms :: Access 2010 - Set Calendar Control As Criteria For Date In VBA Query?

Aug 6, 2013

I need to set calendar control as criteria for date in VBA query. I cannot find Calendar control in ActiveX tools in Acc 2010. Where is it?

Date picker seams like very slick and simple solution but I can see it only in database. As it might be solution to my problem, can date picker be used on a form as criteria for VBA query?

View 6 Replies View Related

Forms :: Combo Box Query - Form That Searches A Table To Show Certain Criteria

Jul 21, 2014

I have created a form that searches a table to show certain criteria. I am having trouble with a part where the table uses a checkbox and I am trying to use a combo box on the search form to return the results based on is it checked? Yes/No or both. When I test it I keep getting Runtime error 3075 missing operator.

The sql I am using is below and when I try and see where it is going wrong it highlights the line.

Code : Me.Filter = strWhere

Code:
Private Sub cmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "#dd/mm/yyyy#"

[Code] .....

View 1 Replies View Related

Setting Query Criteria To Be 'blank' Depending On The Criteria Of A Combo Box

Oct 21, 2006

I have set up a database that stores actions (i.e jobs). In the table; two of the fields are...'required completion date' and 'actual completion date'. I wish to lookup, by using a query, all of the open actions (those which havent yet been complete (i.e the 'actual completion date' is null)) and then later on all those which are overdue (i.e the 'actual completion date' is null And the 'required completion date' <today....this being the criteria for an overdue action).

However, I have used a form which has a combo box which contains the values open and overdue. When a selection has been made I want a form to display with the results depending on the selection that has been made. I am capable of creating a form based on a query, but am unsure of how to construct the query with the correct criteria based on the option that is selected from the form.

Any help would gratefully be appreciated. Thanks

View 5 Replies View Related

How To Query Data For Specific Criteria - Criteria Help

Aug 20, 2007

I have data for hundreds of stores. The data was pulled for the top 15 items by store, so I cannot obtain only the top 5 items that I need. How can I query this data to extract only the top (or bottom) 5 Subjects, by store, based on the percentage column?

StoreSubjectSalesSales %
1516Fiction56431.5-24.15%
1516Audio Unabridged1650.8-231.04%
1516History / Military History10081.1-29.99%
1516Role Playing / Graphic Novels14773.9-20.27%
1516Mystery13152.6-19.84%
1516Audio Abridged1785.9-141.84%
1516SciFi / Fantasy27535.3-7.93%
1516Juv Audio/Video1580.6-100.13%
1516Biography8103.6-15.89%
1516Sports7910.8-15.64%
1516Current Affairs / Law8141.9-14.34%
1516Reference7183-16.22%
1516Juv Non-Bk4585.9-25.02%
1516Science / Tech2961.4-33.98%
1516Movies / TV / Music / Dance3395.3-29.46%
1872Fiction307344.3-7.49%
1872Business134307.5-13.48%
1872Psych / Self Improvement100650.4-10.05%
1872Audio Unabridged29165.9-27.32%
1872Cookbooks57463.3-13.56%
1872Computers59235.7-12.37%
1872Regional59883.4-11.22%
1872Health & Fitness64713.8-10.29%
1872Maps19358.4-27.66%
1872Current Affairs / Law47927.1-11.08%
1872Travel Foreign42583.7-12.27%
1872Religion / Bibles80255.6-6.07%
1872SciFi / Fantasy67641.4-6.49%
1872Study Aids / Notes38299-11.24%
1872Games41745.1-9.79%

View 2 Replies View Related

Forms :: Counting In Forms When Meeting Criteria

Feb 23, 2014

I have created a form that list the hours that people do for different types of activities. What I want to do is to sum the hours of each activity. However, I have some activities that I want to group.

For example, I have Training, Ride Outs and Mentor as types of activities that I want to group and then there are all other types that I want to group as Other.

I would just like to add a formula into the command box of properties.

View 2 Replies View Related

One Set Of Criteria, Multiple Forms

Feb 27, 2008

I'm sure this one has been asked time and time again!

I currently have a set of staff questionairres each on a different table.
Currently when I want to export all the scores for one employee to excel (eventually) I have a macro which runs 7 queries, but each asks for the same criteria (Date To & From) and (Staff Name) in turn - very time consuming!

How do I create a query or macro which will ask once for a date range and an employee name and apply to all of my queries?

I am a novice on access and am trying to do this without SQL

Thanks for your help

View 1 Replies View Related

Use Query Generated Field As Criteria For Another Query?

Apr 2, 2008

I am trying to use a single record and cell of data generated from a query as criteria in another query but can't figure out how to do it? Is there a way to reference a query field in the criteria in design view of another query?

Details:

I have a table of data for each month with supplier codes in each table, but no date field.

I am trying to build a query that will automatically pick the most recent month of data. I have built a query that uses an iif statement in SQL assigning a number to the most recent month of data and then I am using the max filter in that query to show the single highest number (But this logic misses suppliers some suppliers but does assign a number to the most recent set of data). In this case its 2 for february data. I want to use this digit to filter a seperate criteria that will show me all the supplier codes for the month of february. One problem is that some suppliers are in every month others, come and go throughout the year, so I have to assign this criteria for each month. Therefore I want to use the 2 from the first query and plug that into each criteria section under each month field of the second query.

The other option that I can think of but can't seem to find a fix, is to merge all 12 tables so there are duplicate entries and can have a date or number assigned for each month that the supplier code shows up, then just use the max number. I can't seem to find a way to add all the codes creating duplicates into one field. I used a union query but there are no duplicates with this method thus foiling my plan.

Please help
Thanks for reading

View 1 Replies View Related

Form Based On Criteria From 2 Other Forms

Feb 23, 2005

Hi,

I have a form (say Form X) that opens based on the ProjectID criteria in the query, which is based on a record selected from Form1 [ProjectID].

I want to be able to open Form X using information from 2 forms - Form1 or Form2, both using ProjectID. What I've done so far works, but I get an Enter Value Parameter looking for the other Form. How do I write the statement so that it reads Form1 [ProjectID] and if that is not open (null??), then it goes to Form2 [ProjectID] and vice versa?

What I have is:

IIf(("IsNull[Forms]![FrmAddPrjInfo]![ProjectID]"),[Forms]![FrmPrjRvwerMgrDue]![ProjectID],0) Or IIf(("IsNull[Forms]![FrmPrjRvwerMgrDue]![ProjectID]"),[Forms]![FrmAddPrjInfo]![ProjectID],0)

Variations of this haven't worked. Perhaps IIF statement is the wrong way to go about this?

Any suggestions? Thanks!

View 5 Replies View Related

Opening Forms Based On Criteria

Feb 12, 2006

Hello everyone,

I have a problem with opening forms.I have situation with 8 forms (small ones!) which must be open based on values in ComboBox1 and ComboBox2.
Can I do it with Select case (DoubleClick event), and how?

THANK YOU IN ADVANCE,

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved