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.caption = 1 'increment by +1 or -1 if me.recordset.movenext or moveprevious
lblTotalRecords.caption = me.recordset.recordcount
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 YourSubformControl 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:
-
Me.YourSubformControl.RecordsetClone.movelast
-
Me.lblRecords.caption = Me.YourSubformControl.CurrentRecord
-
Me.lblTotalRecords.caption = Me.YourSubformControl.RecordsetClone.RecordCount
If the above does not work,place a textbox named txtRecordIndicator in the desired location on your main form, and place this code on your Form_Current() event for your main form.
-
Me.YourSubformControl.RecordsetClone.movelast
-
Me.txtRecordIndicator.Value = Me.YourSubformControl.CurrentRecord & _
-
" of " & Me.YourSubformControl.RecordsetClone.RecordCount