Query Which Selects Fields?

Mar 17, 2007

Is it possible to create a query which selects selects fields in a table, not just data in a field? If so, how?

TIA

View Replies


ADVERTISEMENT

Queries :: Query Selects Records Twice

Aug 22, 2013

why this query pulls every record twice and what I can do to fix it?I did it in design mode because I'm an amateur, but here is the SQL.

SELECT [Patient Data Table].[First Name], [Patient Data Table].[Last Name], [Patient Data Table].[C MRI Facility], [Patient Data Table].[C MRI Sched Date], [Patient Data Table].[C MRI Scan Done]
FROM [Patient Data Table], [Date Range]
WHERE ((([Patient Data Table].[C MRI Scan Done])=Yes) AND ((Month([C MRI Sched Date]))=[Date Range]![From Month]) AND ((Year([C MRI Sched Date]))=[Date Range]![From Year]));

View 6 Replies View Related

Multiple Selects In An Access Passthru Query

Sep 7, 2005

Hi,

I'm trying to run a pass thru query into a sybase server from Access. The query contains multiple selects which Access doesn't appear to like very much. The query works fine when run in Sybase.

Is there any way of circumventing this problem?

I could split the three selects into three seperate queries to view the individual results but the third set is dependant on the previous two sets and so therefore is difficult (impossible?) to seperate out as a third individual query.

Thanks for any suggestions?

Select
s.id_prtf Portfolio_ID,
s.id_imnt Instrument_ID,
s.id_imnt_swap Instrument_Swap_ID,
s.id_ccy_std Currency,
s.am_posn Position,
s.am_pnl_eqty PNL_Eqty

into #temptable1
from
SET_VALUATION s, INSTRUMENT i
where
s.id_imnt = i.id_imnt
and s.id_posn_ref is NULL
and s.id_imnt_swap is NULL
and s.am_pnl_eqty > 0
and i.id_typ_imnt != 'SFX'

Select
s.id_prtf Portfolio_ID,
s.id_imnt Instrument_ID,
s.id_imnt_swap Instrument_Swap_ID,
s.id_ccy_std Currency,
s.am_posn Position,
s.pr_imnt_mtm_prev,
sy.pr_imnt_mtm,
s.am_mv_prev,
sy.am_mv

into #temptable1a
from SET_VALUATION s, SET_VALUATION_HIST sy, REFERENCE_DATA r
where
s.id_prtf = sy.id_prtf
and s.id_imnt = sy.id_imnt
and s.pr_imnt_mtm_prev != sy.pr_imnt_mtm
and s.am_mv_prev != sy.am_mv
and r.dt_bus_lst = sy.dt_bus

select
t.*,
tt.pr_imnt_mtm_prev,
tt.pr_imnt_mtm,
tt.am_mv_prev,
tt.am_mv

into #newtemp
from #temptable1 t, #temptable1a tt
where
t.Portfolio_ID = tt.Portfolio_ID

delete from #temptable1
where #temptable1.Portfolio_ID in (select Portfolio_ID from #newtemp)
delete from #temptable1a
where #temptable1a.Portfolio_ID in (select Portfolio_ID from #newtemp)

select "Where id_posn_ref is NULL and id_imnt_swap is NULL is the only criteria"
select * from #temptable1
select "Where SET VAL's pr_imnt_mtm_prev does not equal SET VAL HIST's pr_imnt_mtm, is the only criteria"
select * from #temptable1a
select "Where the output satisfies both Where id_posn_ref is NULL and id_imnt_swap is NULL AND Where SET VAL's pr_imnt_mtm_prev does not equal SET VAL HIST's pr_imnt_mtm"
select * from #newtemp

drop table #temptable1
drop table #temptable1a
drop table #newtemp

View 2 Replies View Related

Query Selects No Records, How To Convert Null To Zero

Apr 29, 2008

Simple query, but I need to roll the results up with others and a null return is hurting me. I have been chasing my tail around with the nz(), input masks, IIF statements, only to prove my ignorance and possible insanity for expecting different results.

Here we go:

SELECT Count([LDB LOG].DSTHTL) AS ["tot120"]
FROM [LDB LOG]
WHERE ((([LDB LOG].[LDB Rcvd]) Between Now()-120 And #1/1/2008#))
GROUP BY [LDB LOG].[T-7 Date]
HAVING ((([LDB LOG].[T-7 Date]) Is Null));

This is being used to count open items into age buckets, the above is the greater than 120 days (discounting anything prior to 2008). If the T-7 Date is null the item is open. What is happening is that no records are being selected, resulting in the null value back.

Any help would be greatly appreciated as I have spent an unrealistic amount of time on this.


Thanks
Brendan

View 6 Replies View Related

Queries :: Selects Active Records For Three Different Selections - Concatenate Query Results

Nov 3, 2014

I have a query that selects the "Active" records for three different selections, A, B or C.. There may be 1, 2 or 3 results for a particular selection. That is Selection A may have one result or active records, but Selection B may have three results.

I want to use data from the query to populate a field on a form. For example, if the results for Selection A, having one "Active" record would be RecordAData. But for Selection B with three "Active" records the result would be RecordBData & " " & RecordBData2 & " " & RecordBData3

My query is:
SELECT tblSomething.ID, tblSomething.D1, tblSomething.D2, tblSomething.D3, tblSomething.D4, tblSomething.D5, tblSomething.D6, [D3] & " " & [D4] & " " & [D5] & "-" & [D6] & " " & "SomeText" AS Header
FROM tblSomething
WHERE (((tblSomething.D1)=Forms!frmSomethingHeaders!D1) And ((tblSomething.D2)=True));

The concatenation in the query is labeled "Header". I want to be able to Concatenate the "Header" which in itself is a concatenation in the query.

I thought that this might be a looping through the query results, but I cannot figure out how to do it. But then, that is only my uneducated guess.

View 11 Replies View Related

Queries :: How To Write A Query Which Selects Multiple Records From A Table At Once For Updating

Aug 14, 2013

I have a list box whose data is inserted in a table named as "test0" ,now in a macro of vba i want to select all the items in the list box and create there pdf files in a folder at my desired location. So far i have managed to create a pdf file of single item ,but i want to select multiple items at once ,

Code:
SELECT test0.ID, test0.item FROM test0 WHERE (((test0.item)=[ItemNumber]));

So, in this query itemNumber are multiple and i want to create there pdf files at once ..just on a click of one button ?

View 2 Replies View Related

Deleting Selects Field

Oct 7, 2005

I have this code that works fine exept for one thing. If I have two names that are the same it deletes them both.
currentdb.execute "insert into charmer91 (last,first) values ('"me.list0 & "','" & me.list0.column(1) & "')"
currentdb.execute "delete table1 (last, first) from table1 where last ='"&list0 &"'"
How can I change the delete statement so it only deletes the selected name I have in list0, ie.. the highlighted one?
Basically Im moving data from one table to another via listboxes.

thanks in advance

View 3 Replies View Related

Combo Box Which Selects From One Table Out Of Many?

Aug 9, 2014

So instead of having all of my data on a single table which is filtered out as I make selections in my initial 3 combo boxes, I'd like for each set of data to be on it's own table. Instead of filtering out the irrelevant data in a single table, I'd like the initial 3 combo boxes to instead filter out the irrelevant tables. My main reasoning for doing this is that I figure it would first off save me much trouble in the future when editing data within the tables and also that one huge data table would slow down Access eventually.

View 9 Replies View Related

Using IIF Criteria To Choose Between Two Different Like Selects

Aug 26, 2014

I am setting up an Access database for a small school. The database contains a record per person. When we get a duplicate lastname field we set a family_id field to lastname followed by a number.

So for example the first Smith family needs to family_id. But the second Smith family gets a family_id of smith1. To select an ordered list of Families I need a query that will use the family_id if it is set and if not use the the lastname to collect family members.

My query uses a presorted table, CurStuByGrdTbl , of current students to produce the families directory by grade and alphabetized.

The WellSchoolCommunityAll table is the entire database. So if the student entry has a valid family_id, matching pattern "*#" then

I perform a Like with family.id otherwise I perform a Like with lastname.

This query gets me nothing, no records.

IIf(([CurStuByGrdTbl].[family_id]="*#"),[CurStuByGrdTbl].[family_id] Like [WellSchoolCommunityAll].[family_id],[CurStuByGrdTbl].[lastname] Like [WellSchoolCommunityAll].[lastname])

View 4 Replies View Related

Multiple Selects And Records Store

Dec 21, 2005

I'm creating an Access data entry form for computer installations.

Basically the entry form will choose a software and license, then select one or more computers to install the software on.

Then later we can create a report that can track what softwares are installed on the computers, or track what computers has what softwares.

Now my question is for each record of the installation entry form, after we select the software, then we will choose a computer name or more computer names.
If just one computer is easy, but how can I choose multiple computers, which control should I use? and how can I store the computer name list in the installation table, do I have to make each computer installation a record in the table or put multiple computer names in one record in the field like memo, but if I use memo, later it seems i cannot group or search memo field?

Can anyone give me some ideas about what is an easy design solution or samples about these?

Thanks a lot

View 1 Replies View Related

ListBox Selects Row When Scroll Bar Is Clicked

Oct 31, 2006

I'm using Access 2002 and when I try to scroll up or down it selects the row and then scrolls 1 row. Is this a bug?

thanks
Paul

View 1 Replies View Related

Access Selects All Field Text When Typing

Oct 30, 2012

I have created a database.On opening the [Company] form opens up.After pressing the 'Add new company' button it creates a new record. when typing immediately into the 'Company Name' field, access highlights all the text whilst your typing making you delete what you have just typed.I have tried several macros and vba at various different events to try and solve including 'Gotocontrol', 'refesh'. I have even tried SelStart.

View 1 Replies View Related

Modules & VBA :: If User Selects Wrong Value / Display Message

Feb 23, 2015

I have a field that is pre filled in with a value. The name is "Business".Then there is a combo box with various values. If the user would select a value that does not match with values that can be selected if in "business" a value is selected, it should show a message that the selection is wrong and user needs to select the correct one.

Example:If in the field "Business" the value "Food" is selected, then the possible values to be selected in the combobox would be: Fruit or Meet or Fast Food. If the value in "Business" would be "Wood" only selections could be made: Talble or Chair or Cabinet.So, if a user select "Food' in "Business" and in the combo box "Chair", it should show a message that the wrong selection was made and don't let them use the wrong one.

View 11 Replies View Related

Forms :: Button That Opens Form And Pre-selects A Value In List Box

Aug 24, 2014

I open a form (EntryBasic) for users to enter data in, which is then saved to the only table in the database (MasterTable). The form (EntryBasic) has a list box with four choices: red, white, blue, orange. The button that opens the form is placed on another form (MainForm) The form (EntryBasic) record source is MasterTable.

A user is on the MainForm and needs to add a new record related to red. When user clicks on the button (NewRedEntry), I need the form to open and the list box pre-selected to red.

Is there a macro or VBA code that might simply execute this action, preferably something that can be attached to the NewRedEntry button?Even better, if there are two list boxes, code such code be applied to same NewRedEntry button, where both list box values are pre-selcted with the click of this button?

View 5 Replies View Related

Track Order In Which User Selects Items From A List

May 11, 2012

I am trying to find out if there is a way to track the order in which items are selected from a list. I am a dabbler and any keyword searches that I can think of don't bring up what I am looking. So, here is what I am trying to do:

I have a table of symptoms with 3 fields (ID, Category, and Symptom).I have a combo box that will allows the user to pick a category (using select Distinct on category field). I then have a list box populated with all the symptoms that have a category of whatever the user selected. The problem I am having is that I need to somehow track the order in which the user selects symptoms and then save that order for future reference and to be printed on a report. The order is important because the most severe symptom needs to be listed first.

View 7 Replies View Related

Select 1 Pce Of Data And It Automatically Selects And Inputs Relating Data In A Form

Oct 24, 2007

i would like in a form for a combo box to be able to select an item from a table and input relating information automatically into other boxes in the form..

I have 3 tables: Table 1 has product code and product description.
Table 2 has invoice number company details, address etc.
Table 3 has product code and product description qty and invoice number..
Table 3 relates to table 2 by the invoice number and table 3 product code looks up the product codes available in table 1 and also table 3 looks up the list of products descriptions in table 1 using the combo wizard.
This means the wrong code can be put with wrong description.
What i would like to know is how i select a product description and the product code in the form fills out automatically?? i hope this makes sense please helppppp!!

View 5 Replies View Related

Reports :: Use 1st Query To Populate Fields Then Use 2nd Query To Filter Fields

Apr 30, 2013

Any way in report that I have 2 reference queries just 1 is to populate all details and 2nd query to filter details and will be the final reporting information???

View 5 Replies View Related

Forms :: Total Query - Count Of Fields Based On Data In Other Fields

Jun 28, 2015

I have a query that creates counts of fields based on the data in other fields, basically it tells me that in a table there are two entries with value ABC????? and three of DEF????? , the query works perfectly.

When I create a form to display this data and base the form on the Query I keep getting a message box asking for the ID (key field) from the base table.

If I type * in the box (to denote all values) and press enter I get the results expected.

View 4 Replies View Related

Forms :: Second User Record Changes When First User Selects Record

Jul 31, 2014

I have a database for mutli users which is split. Front end is available separately for 3 users. These users make data entry in the same form from their front end form. This particular form has combo box that retrieves data based on selection in combo box and the use starts filling the data in the subform. Upto this, form is Ok, no problems seen.

But when the second user opens the same form from the split database front end stored in his computer, and once the second user selects another record from the combo box, first user's record also changes immediately to the record of Second user. Both users now have the same record even though the form is separately accessed from front end.

View 1 Replies View Related

Blank Fields In Crosstab Query Based On Previous Query

May 31, 2006

:confused:
I am trying to help someone with a complex problem (so it seems to me) but I will first ask about what should be a simple thing....

First goal: to COUNT the number of times a TYPE of visit is made.
There are several different TYPEs but only interested in tracking 2 of them.

When a crosstab query is created - if one of the 2 parameters are not "met", a blank is returned. I have been reading posts about using NZ and IIf IsNull, etc to get past that - but none of them make any sense to me and the Access help suggestions do not work. Hope someone can make it clear with this information: (can't give more specifics to keep privacy intact)

The SQL was written by Access not by me. :)

Here is an example of the Crosstab SQL (which is using a previous query):

TRANSFORM Count([qryTest2.TYPE]) AS CountOfTYPE
SELECT qryTest2.CID
FROM qryTest2
GROUP BY qryTest2.CID
PIVOT qryTest2.TYPE;

-----------
qryTest2 SQL: (Grouping by to remove dups)

SELECT DISTINCTROW tblM.CID, tblM.[M#], tblM.LNAME, tblM.FNAME, tblM.YMDBIRTH, tblC.ClDOS, tblC.TYPE
FROM tblM LEFT JOIN tblC ON tblM.[M#] = tblC.[M#]
GROUP BY tblM.CID, tblM.[M#], tblM.LNAME, tblM.FNAME, tblM.YMDBIRTH, tblC.ClDOS, tblC.TYPE
HAVING (((tblC.TYPE)="Out" Or (tblC.TYPE)="In"))
ORDER BY tblM.CID, tblM.LNAME, tblM.FNAME;

Thanks for you time! :)

View 1 Replies View Related

Sum Fields In Query

Apr 12, 2006

Basically i want to sum up the total of fields with a currency value in them from a query! how do i do this

e.g. I run a parameter query at present which shows me all mortgage applications by lender for year 2003 (I enter the lenders name) and the loan of each application.

I want it to sum up the value of all loans from this lender. e.g

CaseIDLenderNamePRODUCTDateRecievedLoan required
3058Freedom 820 02/02/2003 £160,000.00
3120Freedom 820 17/03/2003 £80,000.00
3130Freedom 828 22/03/2003 £135,000.00
3153Freedom 838 31/03/2003 £210,000.00

How do i get it to create a new field or basically give me the total of this loan???

View 1 Replies View Related

Add Two Fields To A Query

Aug 22, 2006

I have this query:
SELECT A.*, AppointmentCost - Nz((SELECT SUM(PaymentAmount) FROM tblPayment P WHERE A.AppointmentId = P.AppointmentId),0) AS AppBalance, Date()-AppointmentDate AS DaysOutstanding
FROM tblAppointment AS A;


When I run it shows:
AppointmentID
PaymentID
AppointmentCost
AppBalance
DaysOutStanding

I would like the first and last names of patients to show up in this query
I have a table called tblPatient which has these two fields in it.
Colud you please show how to do this, if it is even possible?

View 1 Replies View Related

Too Many Fields In A Query

Jan 24, 2008

There are 2 types of paths a project can follow: ELC and SDLC. In my database, the user must choose which path they are following for their project.

Once they choose a path, they must then fill in one of the two appropriate grid with dates.

The two grids have around 40 fields each.

I am trying to write a query that looks at the response entered for Path and then looks to see if the user entered dates in the wrong grid. (If they choose ELC, they shouldn't have values in the SDLC grid).

For example: iif(Path="ELC" and SDLCDate1<>Null or SDLCDate2<>Null or ...,SDLCDate40<>Null,"Red",Null)

But typing SDLCDate1...SDLCDate40 <> Null is time consuming, messy and Access probably won't allow such a big query.

Is there any workaround?

Thanks,

View 3 Replies View Related

Query Fields

May 10, 2007

I need to know if there is a way to change the actual field that is displayed in a query through criteria. There is a DB table at work that has been set up very poorly. The field names are months Jan - Dec. I need to change the field in the query every month based on whatever month I am running the report for. It sucks and I need to find a way for the query to automatically select the proper month field.

Is this possible?

View 3 Replies View Related

Adding Query Fields Together

Nov 10, 2005

My company has a microsoft access table with about 1200 IDs containing names, addresses etc.
Now I want to print this out in an excel sheet because I want to create address stickers, but I want every cell in the excell sheet to add information about the columns in the database together. I might be very unclear, let me demonstrate what I mean:
The Acess file might look like this:
id | name | address
1 | john | Street 01
2 | sara | Street 02

Now I want to have 2 excell cells which contain the information like this:
name_address
name_address

In my example, 2 cells with the following information:

john Street 01
sara Street 02

So I dont want 4 cells, I want to add the information together from 1 Id to 1 cell, but I also want to add linebreaks to it, It must eventually become an address sticker

How can this be done?

View 3 Replies View Related

Query Cannot Retrieve Enough Fields

Feb 7, 2007

I'm trying to build a form based on a query to use for data editing/entry purposes.

The only way I can think of to do this is to use a query to get data that is particular to my specified customer.

The first problem I have run into is that one query does not contain enough fields to retreive all the fields in my table.

I figure, perhaps I have made a flaw in my design and shouldn't go further with this until I verify it to be true. I don't think I've made a flaw, but the fact that a query has limited maximum number of fields leads me to think I might have.

Each record in the table I'm querying contains several pieces of numerical data that might be recorded during a service visit.

Obviously I could query the table twice but that doesn't feel like the right way to go about it.

View 3 Replies View Related







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