Hi:
I have a pop up form based on a query.
I am openings the form, and wish to close it immediately if the query has result.
My method is to put a macro in the "on Open" event , which has the following code
IsNull([date]) Close (the form I just opened)
Date is one of the fields in the form.
If the date is null, its supposed to trigger a closing of the form. Unfortunately, what
happens is a blank form appears. I have tried IsEmpty and various other formulations with
no joy! The same thing happens if I use the "Load" or "On Open" events, so I am a bit
perplexed.
If the query DOES have a result, the form appears as it should and the fields are entered.
Can anyone suggest what I should be doing? Is there a proper way to determine if a form
(or a query) is empty?
Best and thanks
John Baker 7 19471
OOPS:
THe second line should have said: I am openings the form, and wish to close it immediately if the query has NO result.
John Baker <Ba******@Verizon.net> wrote:
Why not just create a recordset based on the table/query and check to see if
there is any data in it. If not, dont open the form and if there is, just
continue with your code.
HTH
Paul
"John Baker" <Ba******@Verizon.net> wrote in message
news:4f********************************@4ax.com... OOPS:
THe second line should have said:I am openings the form, and wish to close it immediately if the query has NO result.
John Baker <Ba******@Verizon.net> wrote:
Paul:
The real reason is that I am not certain how to do that. Its the testing for empty or
null that has me foxed.
best
John
"Paul" <pz****@rogers.com> wrote: Why not just create a recordset based on the table/query and check to see if there is any data in it. If not, dont open the form and if there is, just continue with your code.
HTH Paul
"John Baker" <Ba******@Verizon.net> wrote in message news:4f********************************@4ax.com.. . OOPS:
THe second line should have said:I am openings the form, and wish to close it immediately if the query has NO result.
John Baker <Ba******@Verizon.net> wrote:
Quite Simple!!!!!
===============================================
Dim dbs As Database
Dim rst As Recordset
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("YourQueryName", dbOpenDynaset)
With rst
If rst.EOF Then
exit sub
Else
docmd.openform "FormName"
End If
End With
dbs.close
set dbs = nothing
set rst = nothing
================================================
HTH
Paul
"John Baker" <Ba******@Verizon.net> wrote in message
news:ig********************************@4ax.com...
Paul:
The real reason is that I am not certain how to do that. Its the testing for empty or null that has me foxed.
best
John
"Paul" <pz****@rogers.com> wrote:
Why not just create a recordset based on the table/query and check to see if there is any data in it. If not, dont open the form and if there is, just continue with your code.
HTH Paul
"John Baker" <Ba******@Verizon.net> wrote in message news:4f********************************@4ax.com. .. OOPS:
THe second line should have said: I am openings the form, and wish to close it immediately if the query has NO result.
John Baker <Ba******@Verizon.net> wrote:
Paul wrote: Quite Simple!!!!! =============================================== Dim dbs As Database Dim rst As Recordset
Set dbs = CurrentDb() Set rst = dbs.OpenRecordset("YourQueryName", dbOpenDynaset)
With rst If rst.EOF Then exit sub Else docmd.openform "FormName" End If End With
dbs.close set dbs = nothing set rst = nothing
or,
if DCount("*","yourqueryname")>0 then docmd.openform "formname"
Bas Cost Budde wrote: Paul wrote:
Quite Simple!!!!! =============================================== Dim dbs As Database Dim rst As Recordset
Set dbs = CurrentDb() Set rst = dbs.OpenRecordset("YourQueryName", dbOpenDynaset)
With rst If rst.EOF Then exit sub Else docmd.openform "FormName" End If End With
dbs.close set dbs = nothing set rst = nothing
or,
if DCount("*","yourqueryname")>0 then docmd.openform "formname"
Or
Sub Form_Open(Cancel As Integer)
Cancel= me.recordsetclone.recordcount=0
End Sub
This will generate a runtime error in the code that opens the form though.
Trevor Best wrote: Or
Sub Form_Open(Cancel As Integer) Cancel= me.recordsetclone.recordcount=0 End Sub
This will generate a runtime error in the code that opens the form though.
Like "operation was cancelled?" 2501 if I am right.
I like the Cancel= approach. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Lin Ma |
last post by:
Greetings,
In my search application, user can type a number to search. I use LIKE in my
query.
If a query result generates over 10,000 recordsets, it may several minutes
to run.
Is there a...
|
by: Surajit Laha |
last post by:
I am firing a query like:
SELECT TaskName, StartDate FROMTasks
WHERE StartDate >= '01-Aug-2003'
Now the result comes as:
TaskName StartDate
--------------------------
Task1 ...
|
by: Wei Wang |
last post by:
Hi,
I want to do a select in dynamic command, something like:
TRIGGER FUNCTION
DECLARE
table_name_suffix text;
temp_result RECORD;
temp_result2 RECORD;
|
by: Martin Sarsale |
last post by:
Dear All:
Im looking for solutions (Free Software is better) to do query result
caching.
Thanks to the people from #postgresql I know that postgres doesn't do
that by himself and the solution...
|
by: RookieDan |
last post by:
Greetings fellow Accessers!
Im new but in Access, but I have some background in different coding.
I have a programme loading customer data into Access belonging to BMW dealers in Europe.
...
|
by: CCHDGeek |
last post by:
How can I tell if a query result empty (ie there are no records with the specified criteria). I want to change a form's design based on the result of the query it is based how. Does anyone know how...
|
by: dbuchanan |
last post by:
How, at rundime, do I capture the fact that the parametrized query that
fills a CheckBoxList results in an empty set. When the dataset is empty the
CheckBoxList does not appear. I would like to...
|
by: ddtpmyra |
last post by:
how can I capture the query result in PHP?
I have two queries below:
# Fetch the file information
$query ="update filestorage set approved ='Y' where FileID = {$id}";
$query1 ="select...
|
by: reeba |
last post by:
I want to store the query result, in an servlet, into an xml file and display the contents of the xml file on the browser......
my code is as follows:
public void doPost(HttpServletRequest...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |