473,581 Members | 3,306 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 4793
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
9732
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
5213
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...
3
2905
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...
3
2034
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 " & _...
0
8389
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...
17
2060
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...
2
3199
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...
3
2872
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...
2
3674
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...
0
7854
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...
0
7783
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...
0
8134
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. ...
1
7880
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...
0
8157
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...
0
5350
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...
0
3794
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3807
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1394
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.