dbTalk Databases Forums  

Setting query field value to 0 if null?

comp.database.ms-access comp.database.ms-access


Discuss Setting query field value to 0 if null? in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
What-a-Tool
 
Posts: n/a

Default Setting query field value to 0 if null? - 10-21-2003 , 08:40 PM






Have a query which shows all fields from two tables. One table is much
shorter than the other, so several field values are Null values.
I would like to have these set to zero, rather than Null.
Could someone please tell me how to do this?
Thanks in advance >
--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)



Reply With Quote
  #2  
Old   
What-a-Tool
 
Posts: n/a

Default Re: Setting query field value to 0 if null? - 10-22-2003 , 05:12 PM






My thought was something like this, but I don't know the exact syntax, and
also, help says to insert this statement in the control source field. Is
that available for a query? Isn't in field properties

IIF([field]=Null,fieldvalue,0)

???

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)

"What-a-Tool" <Die!FrigginSpammersDieDie!@NoShitSherlock.Net> wrote in
message news:lellb.92595$0Z5.3455 (AT) lakeread03 (DOT) ..
Quote:
Have a query which shows all fields from two tables. One table is much
shorter than the other, so several field values are Null values.
I would like to have these set to zero, rather than Null.
Could someone please tell me how to do this?
Thanks in advance
--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)





Reply With Quote
  #3  
Old   
MeadeR
 
Posts: n/a

Default Re: Setting query field value to 0 if null? - 10-22-2003 , 08:57 PM



Try something like this:

Update tblSomething
Set field1 = 0
Where IsNull(field1)

"What-a-Tool" <Die!FrigginSpammersDieDie!@NoShitSherlock.Net> wrote

Quote:
My thought was something like this, but I don't know the exact syntax, and
also, help says to insert this statement in the control source field. Is
that available for a query? Isn't in field properties

IIF([field]=Null,fieldvalue,0)

???

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)

"What-a-Tool" <Die!FrigginSpammersDieDie!@NoShitSherlock.Net> wrote in
message news:lellb.92595$0Z5.3455 (AT) lakeread03 (DOT) ..
Have a query which shows all fields from two tables. One table is much
shorter than the other, so several field values are Null values.
I would like to have these set to zero, rather than Null.
Could someone please tell me how to do this?
Thanks in advance
--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)



Reply With Quote
  #4  
Old   
What-a-Tool
 
Posts: n/a

Default Re: Setting query field value to 0 if null? - 10-23-2003 , 09:17 PM



Worked out a way to do it, but it seems like a really round-about way :

Took Quantity field from 2 tbls, one with many records, one with few.

Created query to show all from long tbl, but only matching from short, which
leaves many Null value fields in tblShort Cloumn.

Created "Make Table" query to transfer this to a table.

Created Update Query to change value of tblShort Quantity list to zero if
"Is Null" in newly created table.

Created new "Select Query" to read this data and calculate a difference
between these 2 quantity columns.

Run these all from a macro, which leaves my newly updated query with up to
date difference values open.

Is there an easier way? Don't like clicking "yes" to all those warnings that
appear during the run of this Macro.

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)


"What-a-Tool" <Die!FrigginSpammersDieDie!@NoShitSherlock.Net> wrote in
message news:lellb.92595$0Z5.3455 (AT) lakeread03 (DOT) ..
Quote:
Have a query which shows all fields from two tables. One table is much
shorter than the other, so several field values are Null values.
I would like to have these set to zero, rather than Null.
Could someone please tell me how to do this?
Thanks in advance
--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)





Reply With Quote
  #5  
Old   
Bradley
 
Posts: n/a

Default Re: Setting query field value to 0 if null? - 10-23-2003 , 10:31 PM



First, you can set the SetWarnings = False in code or a macro to stop the
messages.

Second, why not just put the field ..

ReplaceNull: iif( IsNull([myField]), 0 [myField] )

in your query to return a zero if the field is null?


--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response

"What-a-Tool" <Die!FrigginSpammersDieDie!@NoShitSherlock.Net> wrote in
message news:aZ%lb.98976$0Z5.472 (AT) lakeread03 (DOT) ..
Quote:
Worked out a way to do it, but it seems like a really round-about way :

Took Quantity field from 2 tbls, one with many records, one with few.

Created query to show all from long tbl, but only matching from short,
which
leaves many Null value fields in tblShort Cloumn.

Created "Make Table" query to transfer this to a table.

Created Update Query to change value of tblShort Quantity list to zero if
"Is Null" in newly created table.

Created new "Select Query" to read this data and calculate a difference
between these 2 quantity columns.

Run these all from a macro, which leaves my newly updated query with up to
date difference values open.

Is there an easier way? Don't like clicking "yes" to all those warnings
that
appear during the run of this Macro.

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)


"What-a-Tool" <Die!FrigginSpammersDieDie!@NoShitSherlock.Net> wrote in
message news:lellb.92595$0Z5.3455 (AT) lakeread03 (DOT) ..
Have a query which shows all fields from two tables. One table is much
shorter than the other, so several field values are Null values.
I would like to have these set to zero, rather than Null.
Could someone please tell me how to do this?
Thanks in advance
--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)







Reply With Quote
  #6  
Old   
What-a-Tool
 
Posts: n/a

Default Re: Setting query field value to 0 if null? - 10-24-2003 , 05:31 PM



Aaaaahhhh! I see said the blind man!
After reading your tips, it came to me in a flash!
Got rid of my macro and all my extra queries and tables and replaced them
with one IIF statement.
I knew there had to be an easier way!

Thanks! Thanks! Thanks!

Maybe you could help with another problem.
I bring a calculated field from another query into a query.
Every time I run query2, I get an input box asking for Parameters for this
field. What is this, and how can I get rid of it?
Thanks again.

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)

"Bradley" <bradley (AT) REMOVETHIScomcen (DOT) com.au> wrote

Quote:
First, you can set the SetWarnings = False in code or a macro to stop the
messages.

Second, why not just put the field ..

ReplaceNull: iif( IsNull([myField]), 0 [myField] )

in your query to return a zero if the field is null?


--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response

"What-a-Tool" <Die!FrigginSpammersDieDie!@NoShitSherlock.Net> wrote in
message news:aZ%lb.98976$0Z5.472 (AT) lakeread03 (DOT) ..
Worked out a way to do it, but it seems like a really round-about way :

Took Quantity field from 2 tbls, one with many records, one with few.

Created query to show all from long tbl, but only matching from short,
which
leaves many Null value fields in tblShort Cloumn.

Created "Make Table" query to transfer this to a table.

Created Update Query to change value of tblShort Quantity list to zero
if
"Is Null" in newly created table.

Created new "Select Query" to read this data and calculate a difference
between these 2 quantity columns.

Run these all from a macro, which leaves my newly updated query with up
to
date difference values open.

Is there an easier way? Don't like clicking "yes" to all those warnings
that
appear during the run of this Macro.

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)


"What-a-Tool" <Die!FrigginSpammersDieDie!@NoShitSherlock.Net> wrote in
message news:lellb.92595$0Z5.3455 (AT) lakeread03 (DOT) ..
Have a query which shows all fields from two tables. One table is much
shorter than the other, so several field values are Null values.
I would like to have these set to zero, rather than Null.
Could someone please tell me how to do this?
Thanks in advance
--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)









Reply With Quote
  #7  
Old   
What-a-Tool
 
Posts: n/a

Default Re: Setting query field value to 0 if null? - 10-25-2003 , 08:58 AM



Figured out the "Parameter" problem. Just had one level too many of "Group
By". Eliminated this, and the request for parameter input went away.

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)

"What-a-Tool" <Die!FrigginSpammersDieDie!@NoShitSherlock.Net> wrote in
message news:6Lhmb.99032$0Z5.10519 (AT) lakeread03 (DOT) ..
Quote:
Aaaaahhhh! I see said the blind man!
After reading your tips, it came to me in a flash!
Got rid of my macro and all my extra queries and tables and replaced them
with one IIF statement.
I knew there had to be an easier way!

Thanks! Thanks! Thanks!

Maybe you could help with another problem.
I bring a calculated field from another query into a query.
Every time I run query2, I get an input box asking for Parameters for this
field. What is this, and how can I get rid of it?
Thanks again.

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)

"Bradley" <bradley (AT) REMOVETHIScomcen (DOT) com.au> wrote in message
news21mb.163182$bo1.126312 (AT) news-server (DOT) bigpond.net.au...
First, you can set the SetWarnings = False in code or a macro to stop
the
messages.

Second, why not just put the field ..

ReplaceNull: iif( IsNull([myField]), 0 [myField] )

in your query to return a zero if the field is null?


--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response

"What-a-Tool" <Die!FrigginSpammersDieDie!@NoShitSherlock.Net> wrote in
message news:aZ%lb.98976$0Z5.472 (AT) lakeread03 (DOT) ..
Worked out a way to do it, but it seems like a really round-about way
:

Took Quantity field from 2 tbls, one with many records, one with few.

Created query to show all from long tbl, but only matching from short,
which
leaves many Null value fields in tblShort Cloumn.

Created "Make Table" query to transfer this to a table.

Created Update Query to change value of tblShort Quantity list to zero
if
"Is Null" in newly created table.

Created new "Select Query" to read this data and calculate a
difference
between these 2 quantity columns.

Run these all from a macro, which leaves my newly updated query with
up
to
date difference values open.

Is there an easier way? Don't like clicking "yes" to all those
warnings
that
appear during the run of this Macro.

--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)


"What-a-Tool" <Die!FrigginSpammersDieDie!@NoShitSherlock.Net> wrote in
message news:lellb.92595$0Z5.3455 (AT) lakeread03 (DOT) ..
Have a query which shows all fields from two tables. One table is
much
shorter than the other, so several field values are Null values.
I would like to have these set to zero, rather than Null.
Could someone please tell me how to do this?
Thanks in advance
--

/ Sean the Mc /


"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)











Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.