473,909 Members | 6,066 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Count records in subform

2 New Member
I have a subform that shows images (0, 1, 2, ...etc) linked to a main form. I would like to display the current record number of total number of records for each linked record on the main form. (ie "Image" X " of " Y).

My problem is that as I move between records on my main form, the record information on the subform does not change. I set the subform to NOT show the navigation button (I put command buttons on the form with that functionality). I have tried:
Initially:

lblRecords.capt ion = 1 'increment by +1 or -1 if me.recordset.mo venext or moveprevious
lblTotalRecords .caption = me.recordset.re cordcount

The values get really messed up as I navigate through the sub-form and main form. I am very frustrated because I thought this would be simple.

I am a VBA neophyte, so please use small words. :-)

Thanks in Advance
Feb 13 '08 #1
2 18649
puppydogbuddy
1,923 Recognized Expert Top Contributor
I have a subform that shows images (0, 1, 2, ...etc) linked to a main form. I would like to display the current record number of total number of records for each linked record on the main form. (ie "Image" X " of " Y).

My problem is that as I move between records on my main form, the record information on the subform does not change. I set the subform to NOT show the navigation button (I put command buttons on the form with that functionality). I have tried:
Initially:

lblRecords.capt ion = 1 'increment by +1 or -1 if me.recordset.mo venext or moveprevious
lblTotalRecords .caption = me.recordset.re cordcount

The values get really messed up as I navigate through the sub-form and main form. I am very frustrated because I thought this would be simple.

I am a VBA neophyte, so please use small words. :-)

Thanks in Advance
If I understood you correctly, you want the counts for your subform records while moving thru different records on the main form. Try this in the Current event of your main form. You have to replace illustrative object names like YourSubformCont rol with their actual names in your application. I am also assuming your label captions are on the main form. If these assumptions are not correct, the code will have to change accordingly:
Expand|Select|Wrap|Line Numbers
  1. Me.YourSubformControl.RecordsetClone.movelast
  2. Me.lblRecords.caption = Me.YourSubformControl.CurrentRecord
  3. Me.lblTotalRecords.caption = Me.YourSubformControl.RecordsetClone.RecordCount
If the above does not work,place a textbox named txtRecordIndica tor in the desired location on your main form, and place this code on your Form_Current() event for your main form.
Expand|Select|Wrap|Line Numbers
  1. Me.YourSubformControl.RecordsetClone.movelast
  2. Me.txtRecordIndicator.Value =  Me.YourSubformControl.CurrentRecord & _
  3. " of " & Me.YourSubformControl.RecordsetClone.RecordCount
Feb 13 '08 #2
gmlscripts
2 New Member
Hah! Perfect and so much simpler than my attempted solutions (plus it works). I actually wanted the count and total records information to be on the sub-form, not the main form. Changing the code was an easy fix.

me.RecordsetClo ne.movelast
Me.lblRecords.c aption = Me.CurrentRecor d
Me.lblTotalReco rds.caption = Me.RecordsetClo ne.RecordCount

Thank you!
Feb 14 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
9117
by: deko | last post by:
I have a form with a subform datasheet - I need code behind the OnDelete event of the subform: Private Sub Form_Delete(Cancel As Integer) 'do something that depends on which record is deleted End Sub This works okay when only one record is selected and the delete key is pressed (or right-click delete is selected - makes no difference). But if multiple records are selected in the datasheet, the code runs for the first
6
4090
by: Matt K. | last post by:
Hi there, I have a form in an Access project that contains a subform which displays the results of a query of the style "select * from where = #a certain date#". In the main part of the form the user can change the date, which will force a requery in the subform to bring up records from the date selected. My question is this... The query in the subform is a very simple one, with only three fields being returned. In the interest of...
0
3647
by: Lauren Quantrell | last post by:
I'm using SQL Server backend on an Access 2K front end. I populate a subform: Forms!myForm.myChild.Form.RecordSource = "myStoredProcedureName" On that form is a control where the controlsource is "= Count()" that shows the user the number of records. What I'm doing now is populating the subform, using the RecordsetClone.RecordCount of the subform to determine if any records were returned, and if not, opening a message box telling the...
0
8417
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...
4
4919
by: misscrf | last post by:
On a main form, there is a subform. I want to make a field that will show how many records there are within that subform. Count on the pk, where the subform's fk = the main form pk.. or something like that. I have this, but not getting it right.. keep getting #name =DCount(tblApplications!AppID,,tblApplications!CandID=Forms!frmCandidateEntry!anCandID) any thoughts? Thanks.
1
4452
by: phaddock4 | last post by:
Being fairly inexperienced at Access 2000, i've been reading many posts here for the last several days, and testing myself to find the best approach to do the following in A2K: SET UP: I have created a MainTable (and related form), which has an associated SubForm (popup) along with its underlying, separate Table. The tables' relationship is one to many respectively. The primary key
4
2222
by: sparks | last post by:
I am trying to fix a database that someone did about 4 yrs ago in access97. The main table just contains demographics and is on the main form of the database. It has a subform on a tab that contains the other information. it is set 1 to 1 in the relationships. simplify if I can
11
9507
by: Beany | last post by:
Hi, Can some please provide me with the code for counting records in a subform and displaying it in a textbox? Does this code go into the control source of the textbox? My subform is called 'Asset subform' within the form 'Form1'.. the textbox will be in the same form. Also im showing records in a subform by selecting a user from a combobox...
0
1857
by: jwbird | last post by:
I have a main form with multiple Subforms that are all displaying Datasheet information related to the Main form record. When I make changes/adds to the records(s) in the subform and tab to another subform, it saves those previous subform records fine, but when I make changes to the subform records and then change the mainform criteria, it doesn't save those subform records. I can use an event to prompt for saving the records on the...
0
10037
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
9879
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
10921
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...
0
9727
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
7249
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
6140
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3359
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.