Queries :: Return Records With Both Empty And Populated Field?

Apr 8, 2013

I am trying to create a query that returns records whether a field has data or not...

There are three fields in question, SSN, DOB (this is a date field), POB (this is a foreign key representing a state in the query shows the actual state). Now unless the criterion is different then I just need the answer for one I can reproduce.

I would like to do this in the criteria box in the query.

The query pulls from one table, some of the employees in this table have the three fields populated some don't. I would like the query to return all employees...

View Replies


ADVERTISEMENT

Return To Empty Field Before Closing

Aug 7, 2015

I have a form that requires a specific combo box selection completed prior to closing or it doesn't register the field ID# in the table or display the payment in the payment query. When I click on the accept button on the form, if [PaymentMethodID] is blank, I want to put up a msg box informing me to "choose a Payment Method", then return the cursor to [PaymentMethodID] field to allow the user to make the appropriate selection.How would I write that in VBA.

View 8 Replies View Related

Queries :: Return Records If One Field Is True And Another False

Jul 23, 2013

I am trying to create a query pulling from several tables. I will use the example below to illustrate what I'd like to do.

I have a field called 'Acc_Num', one called 'Stat_Code', and a third called 'Cat_Code'.

Each 'Acc_Num' can have multiple records because there are multiple Stat_Code and Cat_Code values.

What I want to do is isolate just the Acc_Num records where Stat_Code = 1 and Cat_Code equals A1.

I also want to isolate the Acc_num records where the Stat_code = 1 and where Cat_code does not exist.

View 7 Replies View Related

One Field Auto-populated By The Sum Of The Records Of Another Field

Dec 3, 2007

Hi,

This is my first post. Thank you for reading it. And thank you in advance for your assistance.

I have an invoice table and a payments table. One invoice can have many payments (a deposit, final payment etc). The relationship is created.

I have a form with tabs that hold subforms. One of the tabs contains fields from the Invoice Table (i.e. Invoice Number, Invoice Amount, Total Paid). One other tab has a subform that contacts fields from the Payments table (i.e. Invoice Number, Check Number, Check Amount). I would like to auto-populate the Total Paid field in the Invoice Tab with the SUM of the Check Amount from the Payments tab BY Invoice Number.

This doesnt seem to difficult but I'm having trouble with it. Any assistance would be much appreciated.

Thank you!

View 3 Replies View Related

Queries :: How To Add Populated Text Field At Make Table Run

Nov 3, 2014

I can add to my make table query UDate: Date() that will add a populated field to the output table that has today's date in it.

I can also add something similar like this for example V_Num: [V_Number] and when ran, will prompt with a dialogue box to add some data, it will then create the table with that new field name and populated with the text from the dialogue box.

But how can I automate this to skip the dialogue box and just add it to the expression?

View 3 Replies View Related

Finding Records With Empty Field

Jul 18, 2007

The last field in my table is 'Comments'. I want to find if any record or records with 'Comments' field empty. I created a query and added all fields from my table. In the criteria section I typed Like "null". But the query is not returning records where 'Comments' field is empty. I have deliberately added (for testing) a few records leaving comments field empty. This can be viewed clearly in Table view. But the query I made is not displaying the records. Please help.

View 2 Replies View Related

Need To Select Records With Empty Currency Field

Jan 16, 2006

I've tried the following WHERE clause to return records where the 'costper' field is empty and neither return any results.

WHERE NZ([Transactions].[CostPer])=0

WHERE [Transactions].[CostPer]=0

WHERE IsNull([Transactions].[CostPer])

View 2 Replies View Related

Sum() In Empty Table Doesn't Return Zero

Jun 12, 2007

i have a query with this basic structureSELECT id FROM table1,(SELECT SUM(field2) as total2 FROM table2) - (SELECT SUM(field3) as total3 FROM table3) as totalto understand better let's say that:table1 are clientstable2 is money that enters for clientstable3 is money that exits from clientsi want to obtain a balance. the problem is that if table2 or table3 has no records for certain client, this client is exluded from resultsany ideas?i tried using ISNULL like this:SELECT id FROM table1,ISNULL((SELECT SUM(field2) as total2 FROM table2),0) - ISNULL((SELECT SUM(field3) as total3 FROM table3),0) as totalbut it didn't workedthis is the querySELECT id, UPPER(apellido_titular) + ', ' + nombre_titular AS padre, (SELECT SUM(facturas_items.importe) AS totalf FROM facturas INNER JOIN padres ON facturas.id_padre = padres.id LEFT OUTER JOIN facturas_items ON facturas.id = facturas_items.id_documento WHERE (padres.id = p.id) AND (facturas.fecha_vencimiento < GETDATE())) - (SELECT SUM(recibos_items.importe) AS totalr FROM padres INNER JOIN recibos ON padres.id = recibos.id_padre LEFT OUTER JOIN recibos_items ON recibos.id = recibos_items.id_recibo WHERE (padres.id = p.id)) AS totalFROM padres pWHERE (activo = 1) AND ((SELECT SUM(facturas_items.importe) AS totalf FROM facturas INNER JOIN padres ON facturas.id_padre = padres.id LEFT OUTER JOIN facturas_items ON facturas.id = facturas_items.id_documento WHERE (padres.id = p.id) AND (facturas.fecha_vencimiento < GETDATE())) - (SELECT SUM(recibos_items.importe) AS totalr FROM padres INNER JOIN recibos ON padres.id = recibos.id_padre LEFT OUTER JOIN recibos_items ON recibos.id = recibos_items.id_recibo WHERE (padres.id = p.id)) > 0)ORDER BY UPPER(apellido_titular) + ', ' + nombre_titularsorry for my poor english

View 3 Replies View Related

Queries That Return No Records

Jan 31, 2006

Hi All,

I am wandering if it possible to check programatically whether a query returns a NULL result?

I am writing a program(VB) that involves an IFF statement where if there are records in the query it does a specific calculation & if there are no records returned in the query it does something else. Is this possible to achieve?

Thanks in advance:D

Cheers,

Karv

View 2 Replies View Related

Queries :: Recordset Is Showing As Empty But Query Wizard Returns Records

May 12, 2014

I'm trying to write record set contents to excel. My query runs perfect in access query wizard, but recordset showing as null. My VBA code

Code:

Dim cnn As ADODB.Connection
Dim recordst As ADODB.Recordset
Dim strSQL As String
Dim strPath As String
Dim appXL As Excel.Application
Dim wb As Excel.Workbook

[Code] ....

View 5 Replies View Related

Queries :: Return All Records With Last / Max Date

Apr 10, 2013

My issue surrounds retrieving the last (based on most recent date) set of records based on the most recent date. I have query, containing 2 tables as the sources for the query results. Currently, the query yields:

Field A Field B Field C
123456 AAAA 1/8/13
123456 BBBBI 1/8/13
123456 CCCC 1/8/13
123456 DDDD 1/8/13
123456 EEEEEE 3/10/13
123456 FFFFFF 3/10/13
123456 GGGG 3/10/13
123456 HHHH 3/28/13
123456 IIII 3/28/13
123456 JJJJ 3/28/13

The desired results would be to return all records with the last/max date, so yield:

123456 HHHH 3/28/13
123456 IIII 3/28/13
123456 JJJJ 3/28/13

I have tried the max & last functions, yet no success.

View 1 Replies View Related

Queries :: Query To Return Records For A Given Year

Feb 3, 2014

I'm trying to create a query to show me records for a given year. The issue I'm having is that each record has (4) dates fields and each record can contain null values.Is it possible to do this in a query with data like the example below?

Field 1 ID (1), Field 2 Date (12/22/2012), Field 3 Date (2/06/2013), Field 3 Date (Null), Field 4 Date (Null)

In this example I would want 2013 data but would need to be able to search any year. I could also have dates in all (4) fields

View 3 Replies View Related

Queries :: Return Most Recently Created Records?

Mar 3, 2015

query to return the most recently created records in a composite key field, and only the most recent ones.

there is a screenshot of the composite key field attached

I want to get te records with the highest InvoiceID, there can be multiple records with the same InvoiceID and I want to get all of them.

Using the screenshot as an example I need to query to return the last two records as they both have the Same, highest InvoiceID.

View 6 Replies View Related

Queries :: Return Records With No Data In A Cell?

Apr 4, 2015

I've got a database of club members with names, addresses, contact info etc.

I need to send letters by post to those members that I don't have email addresses for. How to create a query to return a list of people whom I don't have email addresses for.

I know how to mail merge the info with the letter I've written in word, how to group people who's email address cell is empty.

View 1 Replies View Related

Queries :: Return Records With Partial Match

Feb 14, 2014

I understand that a query can accept wildcards in the search criteria but this is different.

I have a form on which a user selects a [product] part number in an unbound combo e.g. "12345-V111".

I then need a subform on the form to list records where the relevant field matches the left most part of this part number but is not necessarily complete. e.g. records with "12345-V1" would be returned, records with "12345-V2" wouldn't. The number of characters recorded in this field will vary, but if the characters that are entered match, then the record should be listed.

In other words, the record entries themselves need to be treated like wildcard entries.

View 7 Replies View Related

Queries :: Return Result When No Records Are Found?

May 2, 2013

Any way to build something into a sub-query that says 'if no records are found, return '0' or some other string'?

Otherwise is there a way to make a master query ignore sub-queries if they return no records?

Allow me to explain in more detail: I have a series of sub-queries, most of these take the sum of several fields from a number of different tables, and I have a main query which combines all of these, to be used as the basis of a summary report.

These queries aren't a problem, but I have a few other essential queries which take the modal (most common....) entry for fields which aren't numerical. So I can't use the sum function.

Now, if all the sub-queries are working then so does the main query, however if one of them fails to find a result, then none of them show up in the main query. I don't know why.

The issue is that depending on the date range selected, some of the tables targeted by the sub-queries don't have any records at all, so when they are run they return nothing. The sum queries can handle this since they just return 0, but those searching for modal records just find nothing (not 0's and not null fields, just blank across all rows).

Here's an example of my sql statement for the modal queries.

Code:
SELECT TOP 1 Trends.Trend AS ModeTboxTalk, "1" AS [Key]
FROM Trends INNER JOIN [Toolbox Talks] ON Trends.TrendID = [Toolbox Talks].TrendID
GROUP BY Trends.Trend, [Toolbox Talks].TrendID, [Toolbox Talks].TalkDate

HAVING ((([Toolbox Talks].TalkDate)<=[Forms]![WeeklyReportSelect]![WeekBox] And ([Toolbox Talks].TalkDate)>[Forms]![WeeklyReportSelect]![WeekBox]-7) AND (([Toolbox Talks].SiteID)=[Forms]![WeeklyReportSelect]![SiteBox]))

ORDER BY Count([Toolbox Talks].TrendID) DESC;

- FYI the weekly select form is where users select the week and site they want to report against. So it would be really peachy if I could tell the above to say something like 'no trend this week' if indeed there were no records.

View 6 Replies View Related

Queries :: Pull Letters From Notes Field If Empty?

Oct 29, 2014

I have a query that holds data based on a field. If the field [Device In] is "TimeStation-1" in TblTime for example it holds "AV" in the field [House]. Trouble is some fields are blank and when this is so I want it to pull the last two letters from the [Notes] field. I have attached the database. The query is [QryDeductionsandSleep Ins].

View 4 Replies View Related

Queries :: SQL Where Statement Linked To Fields When Field Is Empty

May 23, 2013

I'm having trouble with using a where statement linked to fields when the field is empty. I need a way to say if field is null then 'do nothing'/'select all' else use the text from the box.

I have a form (ServicesRCSSearch) which has 3 combo boxes (Location1, Location2 and Location3). These fields are linked to a query. The button on the form generates the query.

My SQL for the query is currently:

Select Services.Key, Services.Location, Services_1.Location, Services_2.Location
From Services, Services_1, Services_2 (copies of the same table all left joined)

Where
((IIf(forms!ServicesRCSSearch!Location1 Is Null,"",services.Location=forms!ServicesRCSSearch! Location1))<>False)

And ((Services_1.Location)=IIf(forms!ServicesRCSSearch !Location2 Is Null,forms!ServicesRCSSearch!Location1,forms!Servi cesRCSSearch!Location2))

And ((Services_2.Location)=IIf(forms!ServicesRCSSearch !Location3 Is Null,forms!ServicesRCSSearch!Location1,forms!Servi cesRCSSearch!Location3))

This works in that it uses the fields to filter the query but when Location1 is empty there are no results as you can see from the code.

View 6 Replies View Related

Return All Records Where An Id Field Occurs More Than 3 Times

Jul 12, 2006

I just can't get my head round this one and can't even think of a keyword phrase to search on!


SELECT CompID, CaseRef, ServicesID, Summary
FROM qryAllStats;

In my query I need to return all records where there are more than 3 instances of field 'ServicesID' .

For instance in the recordset ServicesID 47 occurs 5 times while ServicesID 36 occurs 4 times and all other ServicesIDs occur 3 times or fewer.

I would need to return all of the records with ID 47 and 36. Is this do-able?

View 3 Replies View Related

Query To Return Records Containing 2 Characters In A Field

Sep 5, 2013

I have a field in Access 2010 called Section Number which generally holds two characters. The characters can be numbers, letters, or a combination. Examples are:

01
X1
KA
40

Sometimes this field holds three characters, such as:

01a
02b

I want to write a query that returns only the Section Numbers that contain two characters. The instances where the field holds three characters are too numerous and changeable to use a parameter that says, for example: not "01a" and not "02b"

Is there a way to write a parameter that means "not Section Numbers of three characters" or "not Section Numbers of more than 2 characters"?

View 2 Replies View Related

Queries :: Form Field Return A Null Then Look At Field In Table

Jun 10, 2013

Trying to run a query using criteria to populate the query by looking at information from a field on a form, if from is closed I need that criteria to look at the table and return all date in table.

View 14 Replies View Related

Queries :: Return All Records Shared Between Two Tables LESS THAN 3 TIMES

Nov 1, 2014

I am trying to write an access SQL query that returns all records shared between table1 and table2 LESS THAN 3 TIMES.

application has 4 tables: Patients, AnnualPhysical, Doctors, and PatientPhysicalDoctors.

each patient has an annual physical (once a year), and chooses one doctor per annual physical.

each doctor can only perform three or less annual physicals per year.

It is a small application with less than 1000 records per table.

the query will allow the patient to choose an annual physical doctor once a year from available doctors.

Patients is one-to-many to AnnualPhysical;
AnnualPhysical is one-to-many to PatientPhysicalDoctors;
Doctors is one-to-many to PatientPhysicalDoctors.

query for all records NOT shared between Doctors and PatientPhysicalDoctors is:

SELECT *
FROM Doctors
WHERE NOT EXISTS( SELECT * FROM PatientPhysicalDoctors
WHERE Doctors.DoctorID = PatientPhysicalDoctors.DoctorIDFK );

View 3 Replies View Related

Queries :: Modifying A Query To Return Only Instances Where There Is More Than 3 Records

Sep 26, 2014

I have an existing query, created using the query wizard which works just fine - however, I would like to modify it to return only instances where there are 3 or more records appearing.

Essentially, its an employee history report for a particular action done by those employees, which returns all records between two dates as specified by the user. What I would like to do is only show those employees who have had more than three instances of this action in the given date period.

I am thinking along the lines of DCount? but how it would be phrased in the query?

View 14 Replies View Related

Queries :: Field Is Empty - Query To Update Table But No Result

Feb 26, 2015

I have a created a query which I want to update a table. The field is called DTP. I have the Workingdays2 module in place as well as the Holidays Table. The dates (date only) are called Time in and Transaction date. I want the table to update records only if the entry in Completed is Yes. I have attached screenshot of what I have in query. I am no good whatsoever at VBA so I used the Query design view. It shows how many records will be updated (which is a valid number) and shows me which field will be updated. However when I run the query and then opend the Table the DTP field is empty.

View 2 Replies View Related

Modules & VBA :: Return Multiple Records In A Single Field

Apr 6, 2014

I'm trying to create a report that's based on a query, and the query has three fields: [PersonName], [PersonDate], [PersonShift]. This table holds records for people that worked on certain days and certain shifts. What I want to do is create a report that gives a graphical calendar display of each day in a month, and on any day that the person has a record (and sometimes there are more than one), I'd like to see just the PersonShift records showing in that day's box.

tblPersons
PersonName PersonDate PersonShift
Jason 4/10/14 FIRST
Jason 4/13/14 FIRST
Jason 4/13/14 SECOND

So if I were to print this report for Jason, I'd get all the days in April laid out like a calendar, and on 4/10/14 you'd see "FIRST" in the box, and on 4/13/14. you'd see FIRST and SECOND in the box. All the other boxes would be blank.how to display the calendar, how to display the dates. I'm able to return records to those boxes by creating 31 separate queries, one for each day of the month, and each query returns records for that day. The queries are added to the report as subreports. It all works beautifully.

The thing is, I'm running 31 queries every time I pull the report. Is there a way to code a single field on a report that will run a SELECT statement on the table using variables that are located in fields elsewhere in the record?

If I have a PersonName field on the header of the report, and I have a PersonDate field in the detail of the report's record, can I create a new field in the detail of that record that runs a SELECT statement on qryPersons, and filters the tblPersons by the PersonName on the header of the report and on PersonDate in the record?

I want a field on a report that runs a SELECT statement on tblPersons, I want the field to return only the PersonShift records for that person based upon the PersonDate. Each of the fields on my report have a CalendarDate field, and I want the SELECT statement to return records where the PersonDate matches the CalendarDate, and again, it should only display PersonShift records.

View 2 Replies View Related

Queries :: Design A Query To Show Only Empty Field As TEXT Fields In Table

Mar 2, 2014

I am just querying a single table, no relationship involved with another table. As you can see form the attached jpeg, the ZIP field in some cases is empty. I would run a search using Is NULL but the field is NOT numerical. It's a long story but I had to make this field a TEXT field. Basically, what statement do I have to insert in the criteria field to just pull up the EMPTY ZIP fields?

View 2 Replies View Related







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