473,378 Members | 1,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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.FindRecord
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 10022
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.FindRecord
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.OpenRecordset(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
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...
6
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...
1
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...
2
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...
15
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...
1
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
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...
19
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...
12
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....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.