Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 August 15th, 2008, 10:26 AM
Authorized User
 
Join Date: Mar 2008
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Not Open Form when no data in query

I am using a macro to open a form for data entry with a criteria of machine number as "where" condition. The main form is based on a query and there are several related subforms all relating to the machine number. The problem I am having is that, if there is no data entered in the table for that machine number, I get a big blank screen. How do I get the form NOT to open when the query returns nothing for that machine number?
 
Old August 15th, 2008, 02:44 PM
Authorized User
 
Join Date: Mar 2008
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

D'OH! I solved my problem for now, I just moved the "Close Form" button into the form header so it shows up now. Now, if nothing is scheduled to run on that machine, and the form is opened, at least they can get out of it. I would still like to know how to stop the form from opening in the first place.

 
Old August 21st, 2008, 10:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Is this main form open by yet another form before it? If so, disable the button that opens it if there are no records to view.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old August 21st, 2008, 10:50 AM
Authorized User
 
Join Date: Mar 2008
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, it is opened from another form. I'm not sure how to disable the button that way though. Do I somehow do it in the properties for the button or for the form??

 
Old August 21st, 2008, 11:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

On the calling form's ON CURRENT event, see what the record ID is. Then use a DCOUNT function to count how many records in the called form's record source match that ID. If the DCOUNT is zero, disable the OPEN FORM button, otherwise enable the button.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
Close all MdiChield form from open one form/Button salman .NET Framework 2.0 6 December 10th, 2007 03:21 AM
Open Form, run query, open form Grafixx01 Access 7 April 26th, 2007 11:32 AM
Query data in form Vince_421 Access 2 February 1st, 2007 10:45 AM
Copy data from Excel to open HTML form Bartje Excel VBA 1 September 29th, 2006 04:02 AM
How to Query XML Data from XSLT Form kwilliams XSLT 1 December 3rd, 2005 06:14 AM





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