B
Bruce
This is a partial repost with a different subject line, as
I received no reply to the previous question. Please
excuse the repetition, but I rarely receive a reply if I
do not hear within 24 hours.
I have a form (frmSession) to record a training session,
with fields for subject, instructor, etc. cmdPrevious and
cmdNext are navigation buttons on the form itself (rather
than at the bottom left corner). txtRecordCount is an
unbound text box 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. 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 works as
expected.
To filter by [Subject], I select a value from a combo box
(cboLookupSubject) and apply 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 the navigation buttons are not
enabled and txtCounter is incorrect unless the code also
contains DoCmd.GoToRecord , , acLast, or until I move to
another record using the built-in navigation buttons at
the bottom of the form. The built-in navigation buttons
work as expected, as does the record counter. I would
like to have the navigation buttons I added to the form
work in the same way.
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.
I received no reply to the previous question. Please
excuse the repetition, but I rarely receive a reply if I
do not hear within 24 hours.
I have a form (frmSession) to record a training session,
with fields for subject, instructor, etc. cmdPrevious and
cmdNext are navigation buttons on the form itself (rather
than at the bottom left corner). txtRecordCount is an
unbound text box 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. 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 works as
expected.
To filter by [Subject], I select a value from a combo box
(cboLookupSubject) and apply 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 the navigation buttons are not
enabled and txtCounter is incorrect unless the code also
contains DoCmd.GoToRecord , , acLast, or until I move to
another record using the built-in navigation buttons at
the bottom of the form. The built-in navigation buttons
work as expected, as does the record counter. I would
like to have the navigation buttons I added to the form
work in the same way.
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.