473,787 Members | 2,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to check of a SubForm is empty

Dear reader,

I have a SubForm in witch appear some records as datasheet layout.

I need to check of the SubForm is empty or not. I have tried the following
code but it does not work.

If IsNull(Forms![MasterFormName. .]![SubFormName..]) Then
MsgBox "Form is empty select some records and try again.",
vbOkOnly ,"Warning"
End if

Is there any other code to check the SubForm on records.

Thanks for any help.
Kind regards,
Simon

Oct 4 '06 #1
2 12633
One way: (air code, untested)

Dim rsClone as Recordset
set rsClone =
Forms![MasterFormName. .]![SubFormName..].Form.Recordset Clone
if rsClone.recordc ount = 0 then
msgbox etc
end if
set rsClone = Nothing

I have used rsClone for clarity here. Could do the samething all in
one, as it were, but it's somewhat clumsy-looking then ...

HTH

Jeff

Simon wrote:
Dear reader,

I have a SubForm in witch appear some records as datasheet layout.

I need to check of the SubForm is empty or not. I have tried the following
code but it does not work.

If IsNull(Forms![MasterFormName. .]![SubFormName..]) Then
MsgBox "Form is empty select some records and try again.",
vbOkOnly ,"Warning"
End if

Is there any other code to check the SubForm on records.

Thanks for any help.
Kind regards,
Simon
Oct 4 '06 #2
Simon wrote:
Dear reader,

I have a SubForm in witch appear some records as datasheet layout.

I need to check of the SubForm is empty or not. I have tried the following
code but it does not work.

If IsNull(Forms![MasterFormName. .]![SubFormName..]) Then
MsgBox "Form is empty select some records and try again.",
vbOkOnly ,"Warning"
End if

Is there any other code to check the SubForm on records.
You would create a RecordSetClone and then query its .RecordCount property for a value
greater than 0. If you need a more accurate count then you would force a total read
(perhaps by doing a .MoveLsat followed by a .MoveFirst to force the data to be read
from the server).

--
'---------------
'John Mishefske
'---------------
Oct 4 '06 #3

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

Similar topics

15
24877
by: Rey | last post by:
Howdy all. Appreciate your help with several problems I'm having: I'm trying to determine if the Visit subform (subformVisits) has a new record or been changed, i.e. dirty. The form that contains the subform is named Clients. I have this code in the Add Client btn: If Forms!Clients.subformVisits!VisitDirty = True Then MsgBox "Visit subform is dirty!"
11
11561
by: Ian Ornstein | last post by:
in posting http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&newwindow=1&selm=bmEK9.43452%24lj.1060600%40read1.cgocable.net Lyle showed us that an ADODB.Recordset can be created and attached to a continuous (and datasheet) form. I needed it for a data entry subform and I haven't been able to get it to work. Is there any rational for why it doesn't work with a subForm? Any suggestions for a datasheet data entry subform with two...
0
1388
by: Alienz | last post by:
Hey all. if anyone is REALLY bored please help moi. I am new to access stuff and am probably missing something obvious here. I have 2 tables that are linked via "number" in the relationship area. The relationship is many to many. One is a master form and the other I dragged in to be a subform. I also created a child/master link based on the common "number" field. So, it's a generic subform pretty much.
5
5555
by: Lyn | last post by:
Hi, I have a form which contains a number of subforms in different pages of a tab control. In the detail section of each subform, I list records related to the main form record, but from different tables. In the footer section of the subform I have a Notes text box and three buttons (Add, Update, Delete). The latter each open a separate form for updating or deleting the subform data (the records cannot be updated or deleted directly...
5
3487
by: Susan Bricker | last post by:
Hi. I have a Main form with a subform that has a subform. I have an 'Add Event' button on the Main Form that issues the following instruction: DoCmd.GoToRecord , , acNewRec If the record being displayed BEFORE the 'Add Event' button is clicked does not have data to be displayed (no associated linked records) then when the 'new record' is displayed, the innermost subform looks just fine (all the controls are there and they are empty).
1
3820
by: Shaggers | last post by:
I need to hide/not display a blank row on a subform. The Main form is based on a table, contains Site Header information The Subform is based on another table containing Sample Details records Site Header table to Sample Details table relation ship is one-to-many, with two key fields SiteID and SiteVisitDate The Form/SubForm is linked by SiteID, SiteVisitDate The form adds one record to the Site Header Table.
1
1536
by: Simon | last post by:
Dear reader, I have a SubForm in witch appear some records as datasheet layout. I need to check of the SubForm is empty or not. I have tried the following code but it does not work.
1
4333
by: Cesar Zapata | last post by:
Hi, I have a a bound subform and what i'm trying to do is do check if some criteria applies before saving the record and trigger a macro. basically this is what I got. Date Received InStock UnitPrice
10
5029
Dököll
by: Dököll | last post by:
Me again! I have been battling this one for months. Wrote below to aid in getting certain subforms to hide once checkbox named Active is clicked. I am hoping to make the code work for Date fields that may be empty. I think i am going about it the wrong way: Private Sub Active_BeforeUpdate(Cancel As Integer) 'On current event of main form 'Check if checkbox is selected 'then show or hide subform
0
9655
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
10363
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...
1
10110
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
9964
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...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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.