enable buttons through standard module

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

Greetings,

Several forms in my Access application have form
navigation buttons, i.e. "First Record", "Next Record",
etc. The class modules in each of these forms have the
following code to enable/disable the buttons based on the
current record:

With Me.RecordsetClone
..MoveLast
cmdNextRecord.Enabled = Me.CurrentRecord < .RecordCount
cmdPreviousRecord.Enabled = Me.CurrentRecord > 1
cmdFirstRecord.Enabled = Me.CurrentRecord > 1
cmdLastRecord.Enabled = Me.CurrentRecord < .RecordCount
End With

cmdNewRecord.Enabled = Not Me.NewRecord
cmdDeleteRecord.Enabled = Not Me.NewRecord

Since the identical code appears in multiple forms, I
thought it would be more convenient to create a standard
module and call for it from the form class modules. Since
the "Me" object cannot be used in the standard module, is
there another way to do it?

Any help will be greatly appreciated.

jn
 
-----Original Message-----
Greetings,

Several forms in my Access application have form
navigation buttons, i.e. "First Record", "Next Record",
etc. The class modules in each of these forms have the
following code to enable/disable the buttons based on the
current record:

With Me.RecordsetClone
..MoveLast
cmdNextRecord.Enabled = Me.CurrentRecord < .RecordCount
cmdPreviousRecord.Enabled = Me.CurrentRecord > 1
cmdFirstRecord.Enabled = Me.CurrentRecord > 1
cmdLastRecord.Enabled = Me.CurrentRecord < .RecordCount
End With

cmdNewRecord.Enabled = Not Me.NewRecord
cmdDeleteRecord.Enabled = Not Me.NewRecord

Since the identical code appears in multiple forms, I
thought it would be more convenient to create a standard
module and call for it from the form class modules. Since
the "Me" object cannot be used in the standard module, is
there another way to do it?

Any help will be greatly appreciated.

jn
Hi Jim, use a form parameter...

' call public navigation procedure
UpadeNavButtons me

' procedure in standard module
Public Sub UpdateNavButtons(frm as form)

' substitute me with frm
With frm.RecordsetClone
' rest of code as posted...


Luck
Jonathan
 
Have a look at the code here:
http://www.lebans.com/recnavbuttons.htm
RecordNavigationButtons is an MDB containing code to replace the
standard Navigation Buttons. The custom buttons exactly emulate the
standard navigation bar including the autorepeat property.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Back
Top