Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 19th, 2006, 09:48 AM
Authorized User
 
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Default Values for Query

I have a query that I run on some other queries, but if there isnt any data that matches I want the initial query to put default value of zero in its fields. Is this possible?

Thanks
 
Old September 19th, 2006, 10:57 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Anything is possible. How are you launching the query? Can you post the SQL?


mmcdonal
 
Old September 19th, 2006, 03:38 PM
Authorized User
 
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The the query is in a SubForm and is launched when the form opens

This is the SQL:
SELECT [Repairs - LS - MT].[# of Welds] AS [Long Seam],
       [Repairs - GW - MT].[# of Welds] AS [Girth Weld],
       [Repairs - RW - MT].[# of Welds] AS [Rack Weld],
       ([Repairs - LS - MT]![# of Welds]+[Repairs - GW - MT]![# of Welds]+[Repairs - RW - MT]![# of Welds])/
       ([Progress_MT]![Long Seam]+[Progress_MT]![Girth Weld]+[Progress_MT]![Rack Weld]) AS [% Complete]
FROM [Repairs - LS - MT], [Repairs - GW - MT], [Repairs - RW - MT], Progress_MT;

It feels like there should be a better way to do this but im at a loss.
 
Old September 20th, 2006, 06:30 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I would have to have the database in front of me, but what I might do is use perhaps the On Load event and run the query in code, and then check the record count. If the record count = 0, then substitute your other values.

I know the other posters here should have some more elegant solutions. C'mon folks.

Let me know if you want to go this way and we can work our some code.
I would use ADO or DAO, open a connection and recordset, run the query, check the recordcount. If rs.RecordCount = 0 Then, run the second query with substitute values.



mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Default Field Values tachtenberg Reporting Services 1 February 19th, 2008 05:52 PM
DataGrid Default Values in C# saxitalis C# 0 August 15th, 2007 03:30 PM
Default values in XMLSchema johnnyclock BOOK: Beginning XML 3rd Edition 0 February 3rd, 2006 06:06 PM
Default values? Raymie_C Access VBA 2 May 16th, 2005 11:48 AM
Default Values davest Access VBA 2 October 19th, 2004 05:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.