473,836 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open Forms in Hidden Mode

Firstly I am an older person trying to teach myself to create a project
and teach myself Access VBA programming along the way.

I anticipate a number of problems I will need help with but here goes
with the first
From one form I want to open another form to extract data. I really

want to do this with the form Hidden but initially show the form open
so that I can easily check what is going on.

If I open the form using the DoCmd.OpenForm method with a Where
condition this works Ok even with the form Hidden. If however the
Where Condition is not satisfied the form opens with no data shown in
any of the fields. If I try to access the fields (to check if the
where condition has been met) I receive a Run Time error message error
'2427': You entered an expression that has no value.
My question is "How can I test to see if the Where Condition has been
satisfied and therefore take alternative action?.

I have tried to use an alternative by merely opening the form using
DoCmd.OpenForm without a Where Condition and then use DoCmd.FindRecor d
based on the Where criteria. If this is not met the form remains on
the first record and it is easy to test to see if the criteria has been
met. The problem is that, although this works fine with the form open
normally as soon as the acHidden is used it behaves as if the form
isn't open at all.
What are the "rules" for Hidden forms?

The answers are probably simple but I am banging my head against a
brick wall.

Can anyone help ?

OldAlex

Nov 13 '05 #1
1 10104
pe*****@cyllene .uwa.edu.au wrote:
Firstly I am an older person trying to teach myself to create a
project and teach myself Access VBA programming along the way.

I anticipate a number of problems I will need help with but here goes
with the first
From one form I want to open another form to extract data. I
really want to do this with the form Hidden but initially show the form open
so that I can easily check what is going on.


I assume you mean that the *second* form is the one you want to be hidden.
If I open the form using the DoCmd.OpenForm method with a Where
condition this works Ok even with the form Hidden. If however the
Where Condition is not satisfied the form opens with no data shown in
any of the fields. If I try to access the fields (to check if the
where condition has been met) I receive a Run Time error message error
'2427': You entered an expression that has no value.
My question is "How can I test to see if the Where Condition has been
satisfied and therefore take alternative action?.
Several ways. What is the code that raises this error? You can test the
NewRecord property of the second form. If that is true then the form opened
with zero records satisfyinh the WHERE clause. You could use DCount() to test
to see that you will get at least one record before you even attempt to open the
second form. That would not be my preference if the Record Sorce was large
since you are effectively querying the source twice.
I have tried to use an alternative by merely opening the form using
DoCmd.OpenForm without a Where Condition and then use DoCmd.FindRecor d
based on the Where criteria. If this is not met the form remains on
the first record and it is easy to test to see if the criteria has
been met. The problem is that, although this works fine with the
form open normally as soon as the acHidden is used it behaves as if
the form isn't open at all.
What are the "rules" for Hidden forms?
I don't like that method (less efficient), but don't know of any reason why it
would behave differently on a hidden form.
The answers are probably simple but I am banging my head against a
brick wall.


IMO opening a form for the sole purpose of extracting lookup data from it is
unnecessary. You should just open a RecordSet so you can get at the data
directly. The extra overhead of a form is just not necessary. Using the DAO
object library that would look something like...

Dim db as Database
Dim rs as Recordset
Dim strSQL as String

strSQL = "SELECT FieldName " & _
"FROM TableName " & _
"WHERE SomeField = SomeValue"
Set db = CurrentDB
Set rs = db.OpenRecordse t(strSQL, dbOpenSnapshot)

If rs.EOF = True Then
'No matching records found (do whatever)
Else
'In here values can be extracted by...
SomeVariable = rs!FieldName
End If

rs.Close
Set rs = Nothing
Set db = Nothing


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
10775
by: lauren quantrell | last post by:
When I open an Access form I can have no recordset specified, then in the form's OnOpen event I can do something like: Me.paramaters = "@SomeColumn = 22)" Me.recordsource = "dbo.sproc123" But I can't do this in a report as it will prompt me for the parameters, even though they seem to be defined ahead of the recordsource. I have worked around this by opening reports to a bogus recordsource
6
25714
by: lauren quantrell | last post by:
I have a command button on a continuous subform and I want the user to click it to open a small popup form that opens in the position of the mouse (which is the same as the position of the command button on each record of the continuous subform.) I'm hoping someone can tell me how to do this. Thanks, lq
1
4534
by: iMedia User | last post by:
I have a site where I want to use the Web form validators in two separate forms on a single page. One form allows existing users to log in while the second one allows new users to register. The problem is that if I use the Web Form validation tags, it treats them all as one form (ie...if someone is trying to use the login form, they get an error saying that they have to enter values in the registration form and vice-versa). Any ideas on...
2
2519
by: Eric | last post by:
I am trying to build an app where the stuff in the root directory is open to all, but anything under the Restricted directory requires you to login and I want to use Forms to do it. I'm having trouble getting the web.config to work properly. First I tried to have a second web.config in the sub directory with authentication and authorization set to forms, but it blew up. Next, I tried to modify the root web.config in the following manner...
15
6496
by: kokostik | last post by:
I did a few searches, but couldn't come up with a clear answer to my question. So here it is: If I am in an open form (MyForm1), is it possible to set the RecordSource of an un-opened form (MyForm2). I want to use the OnClose Event of MyForm1. But I do not want to have the MyForm2 open when this happens. My wish it to have the RecordSource of MyForm2 permanently changed by the OnClose Event of MyForm1. Can this be done ? Thanks for...
1
2575
by: Sorin Schwimmer | last post by:
Hi, I tried for the first time a Tix Tree, so, if my question is naive, I apologize upfront. The following code: <code> from Tix import * r=Tk()
13
3556
by: robert.waters | last post by:
Do you have your users rely on the windows taskbar to manage/navigate between the forms they have open, or do you provide another (more robust) method? Does anyone use a custom navigation system (like keeping a selectable list of open forms in a listbox/commandbar/ breadcrumb trail etc.)?
19
19052
by: =?Utf-8?B?R3JlZw==?= | last post by:
How can I tell via code if a Form is already open. Each time my forms load I have some initialization code that runs, but if the form is already open and hidden I don't want that initialization code to run. Thus, I just want to unhide the form. My thought is eveyrtime I go to load a form I could scan through all the open forms in my project and determine whether the one I'm getting ready to load is open or not.
12
11121
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms. Here is a newbie mistake that I found myself doing (as a newbie), and that even a master programmer, the guru of this forum, Jon Skeet, missed! (He knows this I'm sure, but just didn't think this was my problem; LOL, I am needling him) If...
0
9812
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9658
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10534
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10579
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10244
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9364
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6975
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
4004
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3103
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.