Rabu, 31 Mei 2017

Re: [MS_AccessPros] Re: Form Navigation buttons question

 

Yes, but now that I look at it, if you're passing the name of the current form, then IsLoaded will always be True.  Perhaps what you really want is something like:


    If CurrentProject.AllForms("frmMainSwitchBoard").IsLoaded Then
        Forms(strFormName)!cmdOpenfrm_mainswitchboard.Enabled = False
    Else
        Forms(strFormName)!cmdOpenfrm_mainswitchboard.Enabled = True
    End If

    If CurrentProject.AllForms("frmTimesheets").IsLoaded Then
        Forms(strFormName)!cmdOpenfrmTimesheets.Enabled = False
    Else
        Forms(strFormName)!cmdOpenfrmTimesheets.Enabled = True
    End If

… etc.


John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On May 31, 2017, at 11:02 PM, Jim Wagner luvmymelody@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



So John,
this is what I have. Is this what you were going for?

Public Sub ButtonNavigations(strFormName As String) 

If CurrentProject.AllForms(strFormName).IsLoaded = True Then 

       Forms(strFormName)!cmdOpenfrm_mainswitchboard_new.Enabled = False 
       Forms(strFormName)!cmdOpenfrmTimesheets.Enabled = False 
       Forms(strFormName)!cmdOpenrptReports.Enabled = False 
       Forms(strFormName)!cmdOpenrptSchedules.Enabled = False 
       Forms(strFormName)!cmdOpenrpt_Accruals.Enabled = False 
       
   Else 
   
       Forms(strFormName)!cmdOpenfrm_mainswitchboard_new.Enabled = True 
       Forms(strFormName)!cmdOpenfrmTimesheets.Enabled = True 
       Forms(strFormName)!cmdOpenrptReports.Enabled = True 
       Forms(strFormName)!cmdOpenrptSchedules.Enabled = True 
       Forms(strFormName)!cmdOpenrpt_Accruals.Enabled = True 
       
   End If 

End Sub

Jim Wagner


On Wed May 31 2017 13:19:46 GMT-0700 (US Mountain Standard Time), wrmosca@comcast.net [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

Jim


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.

'******Begin code******
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
My nothing-to-do-with-Access blog


---In MS_Access_Professionals@yahoogroups.com, <luvmymelody@yahoo.com> 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

 

 



__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (6)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar