Kamis, 01 Juni 2017

Re: [MS_AccessPros] Re: Form Navigation buttons question

 

Jim-


Is the previous form closed when it opens this new form?  What's the code that opens the second form?  If you're trying to open a new form and then close the current one, of course the old form is still loaded by the time this code runs.  It's a timing issue.  You could try adding a DoEvents to give the other form time to finish closing before you call this procedure, but that might not work.

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 Jun 1, 2017, at 6:43 PM, Jim Wagner luvmymelody@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



John,

I have the following code in another database because it is awesome. But I am seeing an issue with this new database. The issue is that the previous form that was open still has the button disabled including the form that is currently loaded. Is it a memory or network issue? Or something else?

Thank You
Jim Wagner

Public Sub ButtonNavigations(strFormName As String) 

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


    If CurrentProject.AllForms("Vacancy Input").IsLoaded Then 
        Forms(strFormName)!cmdOpenFrmVacancyInput.Enabled = False 
    Else 
        Forms(strFormName)!cmdOpenFrmVacancyInput.Enabled = True 
    End If 
     
     
    If CurrentProject.AllForms("Tracking Complete Input").IsLoaded Then 
        Forms(strFormName)!cmdOpenFrmTrackingCompleteInput.Enabled = False 
    Else 
        Forms(strFormName)!cmdOpenFrmTrackingCompleteInput.Enabled = True 
    End If 
     
     
     If CurrentProject.AllForms("frm_PSS TRACKING INPUT").IsLoaded Then 
        Forms(strFormName)!cmdOpenFrmPssTrackingInput.Enabled = False 
    Else 
        Forms(strFormName)!cmdOpenFrmPssTrackingInput.Enabled = True 
    End If 
     
     
    If CurrentProject.AllForms("frm_Reports").IsLoaded Then 
        Forms(strFormName)!cmdOpenFrmReports.Enabled = False 
    Else 
        Forms(strFormName)!cmdOpenFrmReports.Enabled = True 
    End If 



End Sub 


and on the form load I have

Private Sub Form_Load() 

ButtonNavigations Me.Name 


End Sub

Jim Wagner



On Thu Jun 01 2017 06:15:32 GMT-0700 (US Mountain Standard Time), david.pratt@outlook.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:


Bill, do you have a small example database demonstrating your custom navigation form?  I looked on your web site but did not see one.



---In MS_Access_Professionals@yahoogroups.com, <wrmosca@...> 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@...> 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 (10)

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