Navigation on form

B

Bruce

I have a form to record a training session, with a subform
to record attendance. The main form lists subject,
instructor, etc. cmdPrevious and cmdNext are navigation
buttons on the form itself (rather than at the bottom left
corner). txtRecordCount is an unbounded text box that is
intended to show the total number of records. The form's
On Open event includes the following (underscores indicate
no line break):

cmdPrevious.Enabled = Not Me.CurrentRecord = 1
cmdNext.Enabled = (Me.CurrentRecord = 1 And_
Me.Recordset.RecordCount > 1) Or Me.CurrentRecord <_
Me.Recordset.RecordCount
Me.txtRecordCount = Me.Recordset.RecordCount
Me.RecordSet.AddNew

The first two lines of code enable the navigation buttons
only when there are records. I prefer this to a message
box that says there are no more records. The third line
of code is intended to put the total number of records
into txtRecordCount. The fourth line opens the form at a
new record. The form opens with cmdPrevious enabled, and
cmdNext not enabled, just like with the built-in buttons
at the bottom of the form. txtRecordCount shows one less
than does the built-in counter (because the built-in one
shows the number of the new record, which is OK, because
the counter is not important when showing all records).

txtCounter is intended for use when filtering the
records. To use the exampple of searching by the Subject
field, I filter by selecting a value from a combo box and
applying the following to the combo box's After Update
event:
DoCmd.ApplyFilter, "[Subject]='" & cboLookupSubject_
& "'"

The After Update event also includes code similar to the
form's On Open event, but it does not enable the
navigation buttons or put the correct number into
txtCounter unless the code also contains
DoCmd.GoToRecord , , acLast. I can live with that, but I
would rather not be limited to starting with the last
record.
The other thing I would like to do with the counter is to
show 1 of 12, 2 of 12, etc. txtCounter shows the total,
but I don't know how to show the current (1, 2, etc.). I
know the built-in counter does this, but I would like it
to be right on the form, near the combo box.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top