enable buttons through standard module

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
 
J

Jonathan Parminter

-----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
 
S

Stephen Lebans

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.
 

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

Similar Threads

Navigation Button Flaws 4
Event after data is populated 2
Using an imported code module 8
First / Last nav button disable 1
Subform recordset 6
function assistance 2
Help with coding 3
RecordCount 12

Top