For more ideas on your navigation buttons...
I have a navigation button routine I use on all my forms. Access navigation buttons tend to confuse the average user. They don't always even notice the buttons so I make my own nav bar. Here is the code I call whenever a move to another record is done. Notice I have a textbox named tstFocus. I put the focus on it so the enabling can work. If one of the buttons has focus you can't disable it. txtFocus is a very tiny box so the user can't see it.
Public Sub CheckPosition(frm As Form, ParamArray ctrls())
'Purpose : Enable/disable nav buttons.
' txtFocus is a textbox that is used only to get
' Focus during enabling/disabling. It is just a
' dot on the form placed near nav buttons.
'DateTime : 11/4/2013 12:08
'Author : Bill Mosca
Dim lngRecNum As Long
Dim lngRecCt As Long
Dim x As Integer
lngRecNum = frm.CurrentRecord
lngRecCt = DCount("*", "DataExtractionAccessLog")
frm.txtFocus.SetFocus
frm.cmdGoFirst.Enabled = lngRecNum <> 1
frm.cmdGoLast.Enabled = lngRecNum <> lngRecCt
frm.cmdGoNext.Enabled = lngRecNum <> lngRecCt
frm.cmdGoPrev.Enabled = lngRecNum <> 1
frm.cmdGoNew.Enabled = lngRecCt <> 0
'No Additions should disable "New" button
If frm.AllowAdditions = False Then
frm.cmdGoNew.Enabled = False
End If
'If any cbo's or lst's have a user-defined function for RowSourceType
'they will need to be requeried.
If Not IsNull(ctrls) Then
For x = 0 To UBound(ctrls)
If ctrls(x).ControlSource = "" Then ctrls(x) = Null
ctrls(x).Requery
Next
End If
End Sub
'******End Code******
Regards,
Bill Mosca, Founder - MS_Access_Professionals
http://www.thatlldoit.com
My nothing-to-do-with-Access blog
http://wrmosca.wordpress.com
---In MS_Access_Professionals@yahoogroups.com, <luvmymelody@...> wrote :
Hello all,
I am redesigning an old database and the forms are going to be changed to have some navigation buttons in the form header for more real estate. So I have 6 buttons with transparent properties. My question is that I would like to have the buttons be the same on every form so it is consistent. But if the form related to the button is loaded I want to have the button disabled.
So I put the following code in on load event.below. But I thought this should be in a module and called on every form. But I am stuck at that point. How do I call something like that?
Thank You
Jim Wagner
If CurrentProject.AllForms("frmReportsNew").IsLoaded = True Then
Forms!frmReportsNew!cmdOpenrptReports.Enabled = False
Else
Forms!frmReportsNew!cmdOpenrptReports.Enabled = True
End If
Tidak ada komentar:
Posting Komentar