?
Solved

record count in subform

Posted on 2003-03-21
10
Medium Priority
?
417 Views
Last Modified: 2008-03-10
I am using the following code to return a record count for a filtered subform.  However, When I get a zero return I get an error.  Can someone help?

If Me!EDITS2SUB.Form.CurrentRecord = "0" Then
  Me!Text59 = 0
Else
  Me!EDITS2SUB.Form.RecordsetClone.MoveLast

  Me!Text59 = Me!EDITS2SUB.Form.RecordsetClone.RecordCount
End If

Ed
WA1ED
0
Comment
Question by:wa1ed
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +1
10 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 1000 total points
ID: 8181041
Ed, I had a look at the db - the subform is set to AllowEdits so the CurrentRecord will give a value of 1 unfortunately.

You could set the subform's AllowEdits and AllowAdditions properties to No, or alternatively, use this:
If Me!EDITS2SUB.Form.NewRecord = True Then

Does that work ?
0
 
LVL 54

Expert Comment

by:nico5038
ID: 8181097
Hmm, I just don't code this as it's already visible right of the recordnavigation buttons.
When filtered the text (filtered) has been added, thus warning you it's not the entire recordset.

Or do you want to get rid of that ?

Nic;o)
0
 
LVL 54

Expert Comment

by:nico5038
ID: 8181122
Hmm, an alternative might be to create a field txtReccount on the main form and add in the subform's OnCurrent event:

Parent.txtReccount = Me.RecordsetClone.RecordCount

Nic;o)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8181134
I use this when I either want to get rid of the navigation buttons (which I usually do) or when I need that text for someone who is, for example, partially sighted and can't see the buttons very well. I don't think (although I could be wrong) there is any way of changing Access' navigation button sizes and appearances.
0
 
LVL 58
ID: 8181438
Ed,

RecordCount is a numeric value, so no quotes on the first check:
 
If Me!EDITS2SUB.Form.CurrentRecord = 0 Then
 Me!Text59 = 0
Else
 Me!EDITS2SUB.Form.RecordsetClone.MoveLast

 Me!Text59 = Me!EDITS2SUB.Form.RecordsetClone.RecordCount
End If


Jim.
0
 

Author Comment

by:wa1ed
ID: 8182032
shane

If Me!EDITS2SUB.Form.NewRecord = True Then

Worked great!
Thankyou

Did you look at that form?
Ed
WA1Ed



0
 
LVL 54

Expert Comment

by:nico5038
ID: 8182088
Using:

Parent.Text59 = Me.RecordsetClone.RecordCount

In the onCurrent event of the subform will be safer as using the IF statement in the [refresh] button.

When a user knows the right-click filter method the IF behind the button won't be executed but the OnCurrent event of the subform will.

Nic;o)
0
 

Author Comment

by:wa1ed
ID: 8182096
I maybe too easy giving everyone A's but, If you solve my problems... What else is there to give? :-)
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8183235
Ed, if you want my honest opinion about the look of the form, I have to say I liked the first version you send me better :)

Personally, I never use datasheet view but that's personal preference. Another point I would make is, if you have icons for buttons, also include a controltip or a text label to indicate the button's functionality - the icon might be obvious to us designers but users are a different matter!
0
 

Author Comment

by:wa1ed
ID: 8184801
Thankyou Shane, That is EXACTLY what I was looking for
Ed
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question