473,396 Members | 2,109 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,396 software developers and data experts.

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 12474
One way: (air code, untested)

Dim rsClone as Recordset
set rsClone =
Forms![MasterFormName..]![SubFormName..].Form.RecordsetClone
if rsClone.recordcount = 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
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...
11
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...
0
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...
5
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...
5
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...
1
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 ...
1
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
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 ...
10
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...
0
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...
0
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...

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.