Change value of field to 0 if specific condition exists on oth

MS Office Access

    Next

  • 1. Something like a three-tiered JavaScript menu...
    I have a database in which someone has entered various organizations. Included in the fields are: >County >Town >Organization Name I want to create a user-friendly query to filter these records. This is what I'm thinking of: 1. User opens a form and sees one combo box where they can choose from a list of counties that had been entered in the database. 2. A second combo box pops up. The user chooses "Show all" and the query is run (automatically or after clicking a button whichever is easier for me to do!) or chooses from a list of towns that were entered into the database. 3. A third combo box pops up the same as #2, but the user chooses an organization (or show all). The query is then run. OR all three combo boxes can be visable from the start if option one is too difficult for me. :) I do not know much/if any programming so if this is required, please be specific. :) Thanks a lot, this place is great!
  • 2. Multiple option query to calculate a value
    I can do forms and designs but I am completely lost when it comes to calculations. I can work how to place them and understand that result one can be used in result three. I have 6 fields which contain the past 6 months values for invoices per month I need to make a field that shows the average value of these 6 I need to make a field that shows the % of field6 compared to field5 I need to make a field that shows the % of the average result compared to field6
  • 3. Error Message 3075
    I have been running this standard query for two years. All of a sudden I get this error message. Run Time Error 3075 I am searching for the first character of a middle school name. Left([MSLName],1) Does anyone know why they have stopped working???? I am sure I need to insert something or download a patch? Does anyone know what I can do? Thank You Len
  • 4. Update query using a sub select
    Hi Guys, I have having trouble updating a table with the result of a query to sum a value. The sql is: UPDATE Invoices SET Invoices.SubTotalFees = (SELECT DISTINCTROW Sum([InvoiceMatterSubTotalFees].[SumOfFee]) AS [Sum Of SumOfFee] FROM InvoiceMatterSubTotalFees; ) WHERE (((Invoices.InvoiceNo)=[Forms]![CreateInvoiceDialog]![InvoiceNo])); Its really simple, I just want to update the Invoice field with the sum of some charges which I collect from the select statement. When I run it I get, "operation must be an updatable query". If you have any ideas at all I'd be very grateful.

RE: Change value of field to 0 if specific condition exists on oth

Postby S3Jpc3RpYmFlcg » Sun, 02 Mar 2008 04:01:00 GMT

I have actully used the Iif function as criteria bafore and it worked fine, 
but I did try it in a separate column as well.  Like I said, I'm not all here 
today.






Re: Change value of field to 0 if specific condition exists on oth

Postby S3Jpc3RpYmFlcg » Sun, 02 Mar 2008 05:22:03 GMT

s I explained to Karl earlier, I've been down with the flu the last few days
and bouncing between home and work; I'm a little stupid today. In the column
"Freeze Qty", I want the quantities for records where stocking=0 to be zero
and the quantities where stocking= -1 to remain as is, but also keep all
20,783 records in the report. The 'sum' was calculated in another
query(Freeze1).

Below I have one item where stocking=0 and one where stocking= -1. For
ACM10417, I want the Freeze Qty value to be changed to 0.


item stocking Freeze Qty Count Count Qty Variance Qty
ACM10417 0 1 0 -1
ADFSPRG -1 1 1 1 0


"Conan Kelly" wrote:


Re: Change value of field to 0 if specific condition exists on oth

Postby Conan Kelly » Sun, 02 Mar 2008 06:27:37 GMT

ristibaer,

Using the SQL statement you posted earlier, will this work for you?:

SELECT [PI Freeze].item, [PI Freeze].descrip, [PI
Freeze].prodclas,immaster.stocking, iif(immaster.stocking=0,0, [PI
Freeze].[Freeze Qty]) as [Freeze Qty], [MAST CNT].Count,
Nz([MASTCNT].[Count],0) AS [Count Qty], ([Count Qty]-[PI Freeze].[Freeze
Qty]) AS [Variance Qty]
FROM ([PI Freeze] LEFT JOIN [MAST CNT] ON [PI Freeze].item = [MAST
CNT].item) INNER JOIN immaster ON [PI Freeze].item = immaster.item
GROUP BY [PI Freeze].item, [PI Freeze].descrip, [PI
Freeze].prodclas,immaster.stocking, iif(immaster.stocking=0,0, [PI
Freeze].[Freeze Qty]), [MAST CNT].Count, Nz([MAST CNT].[Count],0), ([Count
Qty]-[PI Freeze].[Freeze Qty]);

If you notice, in the SQL statement above, I replaced your "[PI
Freeze].[Freeze Qty]" field with an IIF() function that has [PI
Freeze].[Freeze Qty] in the "FALSE" argument ofthe IIF() function.

If, for some reason Access doesn't like you giving an alias to a calculated
column that is the name of an existing column ("as [Freeze Qty]"), change
"as [Freeze Qty]" to something like "as [New Freeze Qty]". But I don't
think Access will have a problem with that.

HTH,

Conan





"Kristibaer" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...



Re: Change value of field to 0 if specific condition exists on oth

Postby S3Jpc3RpYmFlcg » Sun, 02 Mar 2008 06:35:02 GMT

layed with it a bit more. Seems to have finally worked with the following:

SELECT [PI Freeze].item, [PI Freeze].descrip, [PI Freeze].prodclas, [PI
Freeze].[Freeze Qty], IIf([immaster].[stocking]=0,[Freeze Qty],0) AS Freeze,
Nz([MAST CNT].[Count],0) AS [Count Qty], ([Count Qty]-[PI Freeze].[Freeze
Qty]) AS [Variance Qty], immaster.stocking
FROM ([PI Freeze] LEFT JOIN [MAST CNT] ON [PI Freeze].item = [MAST
CNT].item) INNER JOIN immaster ON [PI Freeze].item = immaster.item;

Thanks again!. I'm probably heading home and to bed soon-I'm fading fast.

Have a great weekend,
Kristi

"Conan Kelly" wrote:


Similar Threads:

1.Change value of field to 0 if specific condition exists on other f

I have a query that has a field with a calculation that is a sum of two other 
fields.  I also have another field that detirmines the type of item within a 
record, specifically stocking(displays as -1) and non-stocking (displays as 
0). 

Have tried variations of   IIF([immaster].[stocking] = 0, 0, 
[Field1]+[Field2])
in criteria of fileds and as new fields, but my record count changes from 
20,783 to 382 or I get no results.

Is there an expression I can use in the criteria of the field that is the 
sum of two fields that will default the sum result to zero if the item type 
field is non-stocking?  Here is the SQL statement if this helps explain what 
I am trying to do:

SELECT [PI Freeze].item, [PI Freeze].descrip, [PI Freeze].prodclas, 
immaster.stocking, [PI Freeze].[Freeze Qty], [MAST CNT].Count, Nz([MAST 
CNT].[Count],0) AS [Count Qty], ([Count Qty]-[PI Freeze].[Freeze Qty]) AS 
[Variance Qty]
FROM ([PI Freeze] LEFT JOIN [MAST CNT] ON [PI Freeze].item = [MAST 
CNT].item) INNER JOIN immaster ON [PI Freeze].item = immaster.item
GROUP BY [PI Freeze].item, [PI Freeze].descrip, [PI Freeze].prodclas, 
immaster.stocking, [PI Freeze].[Freeze Qty], [MAST CNT].Count, Nz([MAST 
CNT].[Count],0), ([Count Qty]-[PI Freeze].[Freeze Qty]);

Not quite sure how to create this in a new column.

thanks,
Kristi


2.Changing value to 0 if condition exists in another field of re

Fast fingers ---
  IIF([immaster].[stocking] = 0, 0, [Field1]+[Field2])

-- 
KARL DEWEY
Build a little - Test a little


"KARL DEWEY" wrote:

> You lost me but here is a guess --
>   IIF([immaster].[stocking] = 0, 0, [Field1]+[Field1])
> -- 
> KARL DEWEY
> Build a little - Test a little
> 
> 
> "Kristibaer" wrote:
> 
> > I have a query that has a field with a calculation that is a sum of two other 
> > fields.  I also have another field that detirmines the type of item within a 
> > record, specifically stocking(displays as -1) and non-stocking (displays as 
> > 0). 
> > 
> > Is there an expression I can use in the criteria of the field that is the 
> > sum of two fields that will default the sum result to zero if the item type 
> > field is non-stocking?  Here is the SQL statement if this helps explain what 
> > I am trying to do:
> > 
> > SELECT [PI Freeze].item, [PI Freeze].descrip, [PI Freeze].prodclas, [PI 
> > Freeze].[Freeze Qty], Nz([MAST CNT].[Count],0) AS [Count Qty], ([Count 
> > Qty]-[PI Freeze].[Freeze Qty]) AS [Variance Qty], immaster.stocking
> > FROM ([PI Freeze] LEFT JOIN [MAST CNT] ON [PI Freeze].item = [MAST 
> > CNT].item) INNER JOIN immaster ON [PI Freeze].item = immaster.item
> > GROUP BY [PI Freeze].item, [PI Freeze].descrip, [PI Freeze].prodclas, [PI 
> > Freeze].[Freeze Qty], [MAST CNT].Count, Nz([MAST CNT].[Count],0), ([Count 
> > Qty]-[PI Freeze].[Freeze Qty]), immaster.stocking;
> > 
> > thanks,
> > Kristi
> > 

3.Changing value to 0 if condition exists in another field of record

I have a query that has a field with a calculation that is a sum of two other 
fields.  I also have another field that detirmines the type of item within a 
record, specifically stocking(displays as -1) and non-stocking (displays as 
0). 

Is there an expression I can use in the criteria of the field that is the 
sum of two fields that will default the sum result to zero if the item type 
field is non-stocking?  Here is the SQL statement if this helps explain what 
I am trying to do:

SELECT [PI Freeze].item, [PI Freeze].descrip, [PI Freeze].prodclas, [PI 
Freeze].[Freeze Qty], Nz([MAST CNT].[Count],0) AS [Count Qty], ([Count 
Qty]-[PI Freeze].[Freeze Qty]) AS [Variance Qty], immaster.stocking
FROM ([PI Freeze] LEFT JOIN [MAST CNT] ON [PI Freeze].item = [MAST 
CNT].item) INNER JOIN immaster ON [PI Freeze].item = immaster.item
GROUP BY [PI Freeze].item, [PI Freeze].descrip, [PI Freeze].prodclas, [PI 
Freeze].[Freeze Qty], [MAST CNT].Count, Nz([MAST CNT].[Count],0), ([Count 
Qty]-[PI Freeze].[Freeze Qty]), immaster.stocking;

thanks,
Kristi

4.using query conditions to return a specific value or all value

Thank you very much Ken
Your help is much appreciated!
AC

"Ken Snell [MVP]" wrote:

> Use this as the criterion expression:
> 
> [Forms]![FormName]![ComboBoxName] Or [Forms]![FormName]![ComboBoxName] Is 
> Null
> -- 
> 
>         Ken Snell
> <MS ACCESS MVP>
> 
> 
> "ac512" < XXXX@XXXXX.COM > wrote in message 
> news: XXXX@XXXXX.COM ...
> > using Access 2002...
> > I am trying to construct a query, using criteria which is selected from a
> > combo box on a form.  If a value is selected in the combo box, then the 
> > query
> > will return only the value selected, but if no value is selected in the 
> > combo
> > box (therefore the combo box has a null value) then the query will return 
> > all
> > values.  Using an IIF statement in the query criteria field, I can get the
> > query to return the appropriate results if a value is selected from the 
> > combo
> > box, but I am not able to return all values if nothing is selected in the
> > combo box 
> 
> 
> 

5.using query conditions to return a specific value or all values

using Access 2002...
I am trying to construct a query, using criteria which is selected from a 
combo box on a form.  If a value is selected in the combo box, then the query 
will return only the value selected, but if no value is selected in the combo 
box (therefore the combo box has a null value) then the query will return all 
values.  Using an IIF statement in the query criteria field, I can get the 
query to return the appropriate results if a value is selected from the combo 
box, but I am not able to return all values if nothing is selected in the 
combo box

6. Apply field value from subform to field value from another subform with condition

7. Changing an existing field to VarChar type also changes the field width

8. Changing an existing field to VarChar type also changes the field width



Return to MS Office Access

 

Who is online

Users browsing this forum: No registered users and 13 guest