473,799 Members | 2,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Do not display form when no records, please help...

Hi all,

I have a form to list records (frmListIssue) which I call from different
other forms. My wish is to display a message when the form is called and
empty; no records to display. I want to use OpenArgs because sometimes I
don't want an empty form and sometime I don't. I tried everything, but
until now without success. I hope that someone can help me out here.

This is an example how I call the form:

Dim stDocName As String
Dim strSQL As String
strSQL = "SELECT * FROM tblIssue INNER JOIN tblIssueExcepti on " & _
"ON tblIssue.Issue_ ID = tblIssueExcepti on.Issue_ID " & _
"WHERE (((tblIssueExce ption.Exception _ID)=" & _
Me.cboException _ID & "));"

stDocName = "frmListIss ue"
DoCmd.OpenForm stDocName, , , , , , "CloseIfNoD ata"

Forms!frmListIs sue.RecordSourc e = strSQL
And this is what I have in the On Open event of the form that lists
records:

If Forms!frmListIs sue.RecordsetCl one.BOF And _
Forms!frmListIs sue.RecordsetCl one.EOF And _
Me.OpenArgs = "CloseIfNoD ata" Then
MsgBox "There were no records to display."
End If

The Msgbox is not displayed when the form is empty.
I appreciate all help!
Thanks!

Sandy

Nov 13 '05 #1
9 4816
Of course, I meant: sometimes I don't want an empty form and somtimes I
do.

Sandy <an*******@usen et.com> wrote in
news:Xn******** ***********@194 .109.133.133:
Hi all,

I have a form to list records (frmListIssue) which I call from
different other forms. My wish is to display a message when the form
is called and empty; no records to display. I want to use OpenArgs
because sometimes I don't want an empty form and sometime I don't. I
tried everything, but until now without success. I hope that someone
can help me out here.


Nov 13 '05 #2
Would it make sense to look at the record source of the target form in the
calling form and make your decision to open based on the results.

You could create a function, let's say, IsIssueData(), and modify your
calling procedure. When you want to open regardless of data, just open,
when you don't

If IsIssueDate = -1 then
do something else
Else
docmd.openform. ..
End If

hth,
tim

"Sandy" <an*******@usen et.com> wrote in message
news:Xn******** ***********@194 .109.133.133...
Hi all,

I have a form to list records (frmListIssue) which I call from different
other forms. My wish is to display a message when the form is called and
empty; no records to display. I want to use OpenArgs because sometimes I
don't want an empty form and sometime I don't. I tried everything, but
until now without success. I hope that someone can help me out here.

This is an example how I call the form:

Dim stDocName As String
Dim strSQL As String
strSQL = "SELECT * FROM tblIssue INNER JOIN tblIssueExcepti on " & _
"ON tblIssue.Issue_ ID = tblIssueExcepti on.Issue_ID " & _
"WHERE (((tblIssueExce ption.Exception _ID)=" & _
Me.cboException _ID & "));"

stDocName = "frmListIss ue"
DoCmd.OpenForm stDocName, , , , , , "CloseIfNoD ata"

Forms!frmListIs sue.RecordSourc e = strSQL
And this is what I have in the On Open event of the form that lists
records:

If Forms!frmListIs sue.RecordsetCl one.BOF And _
Forms!frmListIs sue.RecordsetCl one.EOF And _
Me.OpenArgs = "CloseIfNoD ata" Then
MsgBox "There were no records to display."
End If

The Msgbox is not displayed when the form is empty.
I appreciate all help!
Thanks!

Sandy

Nov 13 '05 #3
Thanks Tim,
I will try to do something like that, but that still doesn't explain why my
code doesn't work...

Sandy

"Tim Mills-Groninger" <ti***@earthlin k.net> wrote in
news:iU******** *********@newsr ead3.news.atl.e arthlink.net:
Would it make sense to look at the record source of the target form in
the calling form and make your decision to open based on the results.

You could create a function, let's say, IsIssueData(), and modify your
calling procedure. When you want to open regardless of data, just
open, when you don't

If IsIssueDate = -1 then
do something else
Else
docmd.openform. ..
End If

hth,
tim

Nov 13 '05 #4
This drives me crazy, despite the code below, the form is opened empty!
It is ok that it is empty, but not ok that it opens when it is empty.

Even stranger is: if I display the Me.recordsetclo ne.recordcount, then it
says there are 19 records!!?? But there are none!!

I am lost... Please help...

Thanks, Sandy
Sandy <an*******@usen et.com> wrote in news:Xns965C5CA D8E6B5anony@
194.109.133.133 :
Hi all,

I have a form to list records (frmListIssue) which I call from different other forms. My wish is to display a message when the form is called and empty; no records to display. I want to use OpenArgs because sometimes I don't want an empty form and sometime I don't. I tried everything, but
until now without success. I hope that someone can help me out here.

This is an example how I call the form:

Dim stDocName As String
Dim strSQL As String
strSQL = "SELECT * FROM tblIssue INNER JOIN tblIssueExcepti on " & _
"ON tblIssue.Issue_ ID = tblIssueExcepti on.Issue_ID " & _
"WHERE (((tblIssueExce ption.Exception _ID)=" & _
Me.cboException _ID & "));"

stDocName = "frmListIss ue"
DoCmd.OpenForm stDocName, , , , , , "CloseIfNoD ata"

Forms!frmListIs sue.RecordSourc e = strSQL
And this is what I have in the On Open event of the form that lists
records:

If Forms!frmListIs sue.RecordsetCl one.BOF And _
Forms!frmListIs sue.RecordsetCl one.EOF And _
Me.OpenArgs = "CloseIfNoD ata" Then
MsgBox "There were no records to display."
End If

The Msgbox is not displayed when the form is empty.
I appreciate all help!
Thanks!

Sandy


Nov 13 '05 #5
Private Sub Form_Open(Cance l As Integer)
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClo ne
If rst.BOF And rst.EOF Then
MsgBox "No records to display."
DoCmd.CancelEve nt
End If
Set rst = Nothing
End Sub

Nov 13 '05 #6
Thanks Gord,

But your code doesn't work.
The form is opened, while there are no records to display.

I really hope someone can explain this.

"Gord" <gd*@kingston.n et> wrote in news:1116685549 .588256.133700
@g47g2000cwa.go oglegroups.com:
Private Sub Form_Open(Cance l As Integer)
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClo ne
If rst.BOF And rst.EOF Then
MsgBox "No records to display."
DoCmd.CancelEve nt
End If
Set rst = Nothing
End Sub


Nov 13 '05 #7

Usenet wrote:
This drives me crazy, despite the code below, the form is opened empty! It is ok that it is empty, but not ok that it opens when it is empty.

Even stranger is: if I display the Me.recordsetclo ne.recordcount, then it says there are 19 records!!?? But there are none!!

I am lost... Please help...

Thanks, Sandy


How are you determining that there is no data?
Is Exception_ID an autonumber?
If Exception_ID si NOT an autonumber, could somehow blank records been
created?

Your filter criteria:
"WHERE (((tblIssueExce ption.Exception _ID)=" & _
Me.cboException _ID & "));"

Nov 13 '05 #8
There is no data, I know this because I know the tables and the form
opens empty. But when I include something like

MsgBox rst.RecordCount

It tells there are 19 records (???) and then the form opens empty.

Yes, exception_ID is autonumber.
If I run my select statement as query it seems ok: it doesnot return any
records...

What seems to be wrong here?

Sandy
"rq******@sympa tico.ca" <rq******@sympa tico.ca> wrote in
news:11******** *************@g 47g2000cwa.goog legroups.com:

How are you determining that there is no data?
Is Exception_ID an autonumber?
If Exception_ID si NOT an autonumber, could somehow blank records been
created?

Your filter criteria:
"WHERE (((tblIssueExce ption.Exception _ID)=" & _
Me.cboException _ID & "));"


Nov 13 '05 #9
Sandy <an*******@usen et.com> wrote in
news:Xn******** ***********@194 .109.133.133:
There is no data, I know this because I know the tables and
the form opens empty. But when I include something like

MsgBox rst.RecordCount

It tells there are 19 records (???) and then the form opens
empty.

Yes, exception_ID is autonumber.
If I run my select statement as query it seems ok: it doesnot
return any records...

What seems to be wrong here?

Sandy
A closer look at your original code told me what's wrong.
stDocName = "frmListIss ue"
DoCmd.OpenForm stDocName, , , , , , "CloseIfNoD ata"

Forms!frmListIs sue.RecordSourc e = strSQL
The open event in your called form is firing before the change
of the recordsource.

Possible fix options: 1)move the test to the on load event,
2) call the form with a where clause, if the form's query
differs from your SQL in the Where clause,
3) test your recordset in the calling form, and only open it if
the test returns records.

Q.
"rq******@sympa tico.ca" <rq******@sympa tico.ca> wrote in
news:11******** *************@g 47g2000cwa.goog legroups.com:

How are you determining that there is no data?
Is Exception_ID an autonumber?
If Exception_ID si NOT an autonumber, could somehow blank
records been created?

Your filter criteria:
"WHERE (((tblIssueExce ption.Exception _ID)=" & _
Me.cboException _ID & "));"


--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #10

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

Similar topics

2
9741
by: owais | last post by:
H I want to display progress bar during execution of windows form. When I execute DTS package the form will idle till the DTS package finishes Please help me in this regard. its an urgen Thank owais ---
1
5234
by: Robert | last post by:
Need some help with this please. Is there a way to display more than one record at a time on a popup form? I have a main form that has a button that triggers a popup form that is a continuous form displaying varying numbers of records depending on the crietria selected on the main form. Must be missing something obvious - but can't get it to work no matter what combination of property settings is used for both the pop up form itself...
3
2916
by: DataBard007 | last post by:
My Access 97 database has a form that contains text boxes that display people's names, addresses, phone numbers, etc. The record source is a single table. I created a NextRecord and Previous Record command button that, when clicked, will display the next record and the previous record, respectively. But what if I want a quick glance at all my records? Is there a way to get the records to display automatically, one after another, with a...
3
2043
by: Daniel Tan | last post by:
Hi, i got a subform and inside got some records. But i want to press a button and make all those records to a report. It only display all those records with same Job Order no. I want to display all job order no. and part. Pls advise. partid = " = '" & Forms!main!Overdue_sub.Form!Part_No & "' " MyReport = "select * from overdue_qry " & _ "where" & " = '" & Forms!main!Overdue_sub.Form!Jobid
0
8411
by: Carl | last post by:
I have a main form with navigation buttons on it and a label showing for example Record 1 of 15 using recordsetclone on it and eveything works fine. When I move through the records the record number changes fine. Within this main form I have a subform detailing distribution records for the contact (main form is based on this) that also has navigation buttons and a label showing Distribution 1 of ##. This is where the problem lies. The...
17
2083
by: perryche | last post by:
I have 5records, e.g. Rc1, Rc2, Rc3..., when user open up a form, I want it to open to a particular record (say Rc3) then when user chooses the Record Selector , it will go to Rc2 and , it will go to Rc4. If I use Sort in the query, it is sorted alphabetically; if I do not sort, whatever is the latest record will be on top. Any help/insight will be appreciated. Perry
2
3209
by: kev | last post by:
Hi Folks, I have created a search query in which it successfully returns correct results. When there are no records returned, instead of giving out a blank form i created a pop-up msg which is attached to the On Open event. However, right after the msg box pops saying"no records", this is followed by another msg box with "TheOpen Form action was cancelled". Is there a way i can eliminate the second msg box from appearing?
3
2885
by: WiseG1rly | last post by:
Hey everyone! I am completley new and I will start off by saying that I am not a programmer - figuring out this search took so long! I am debugging now and would appreciate any help :) Anyways, I am creating a website where I have a database of pet listings in california. Each record lists the Type of Listing (eg. dog grooming or vet) the the Area it is in (so state, county etc.), a Name, Description, and Address. I created a search...
2
3689
by: kurtzky | last post by:
i created a form that should function as follows: i will enter a number in a textbox..then it should query from the database all the records which has that number..these records will have a different item no in it..then, these records will be saved in a temporary datatable (which i made in a separate class, the name is WBASKET)...The item nos of these records will be displayed in a combobox, say item1, item2, etc.. then,i have a datagrid...
0
9686
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
9540
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
10475
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10250
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
10222
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
9068
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
6805
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();...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.