Results 1 to 2 of 2
  1. #1
    Misjel is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Location
    Belgium
    Posts
    12

    Red face Problem with NavigationButtons in a NavigationForm

    Hi,
    I have been trying to solve a problem for days.
    I have a NavigationForm with about 50 NavigationButtons. I wrote a small module to turn these buttons on or off per user. This works perfectly except for 3 buttons.
    This is the underlying code of a NavigationButton:
    If TempVars("InUitSchakelen") Then
    Call modInUitSchakelen(TempVars("Shopbeheerder"), frmnm, Me.ActiveControl.Name, Me.ActiveControl.Caption)
    End If
    This is the code for the actual processing:
    Public Sub modInUitSchakelen(InUit, frm, ctl, cap)
    On Error GoTo Proc_Error
    DoCmd.Hourglass True
    If InUit = "xxxxxxxx" Then GoTo Proc_Exit
    Dim rs As DAO.Recordset
    Dim db As DAO.Database
    Dim strsql As String
    strsql = "SELECT * FROM FormBevoegdheden WHERE Identificatie = " & Chr(34) & InUit & Chr(34) & " ;"
    Set db = CurrentDb()
    Set rs = db.OpenRecordset(strsql, dbOpenDynaset)
    With rs
    If .RecordCount > 0 Then
    .MoveFirst
    Do Until .EOF
    Forms(frm).Controls(ctl).bordercolor = vbRed
    .MoveNext
    Loop
    End If
    End With
    rs.Close
    Set rs = OpenSeek("FormBevoegdheden")
    With rs


    .Index = "Primarykey"
    .Seek "=", frm, ctl, InUit
    If .NoMatch Then
    .AddNew
    !Form = frm
    !Control = ctl
    !Identificatie = InUit
    .Update
    Forms(frm).Controls(ctl).bordercolor = vbRed
    Else
    .Delete
    Forms(frm).Controls(ctl).bordercolor = vbBlack
    End If
    End With

    Proc_Exit: On Error Resume Next
    rs.Close
    db.Close
    Set rs = Nothing
    Set db = Nothing
    DoCmd.Hourglass False
    Exit Sub

    Proc_Error:
    If err.Number = 2220 Then
    Resume Next
    End If
    Call errfout(err.Number, err.Description)
    Resume Proc_Exit

    End Sub
    See attachment: Screenshot 2025-05-31 104535.jpg
    The Me.ActiveControl.Name should be NavigationButton4212 but when I run the Add Watch I get: NavigationSubform and then the error: 438 Object doesn’t support this property or method.
    Hopefully someone will give me a positive answer because I can’t find it (the properties of the wrong button are the same as those of a correct button).
    Thanks in advance
    Regards
    Michel
    Attached Thumbnails Attached Thumbnails Screenshot 2025-05-31 104535.jpg  

  2. #2
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    Code:
    Set rs = OpenSeek("FormBevoegdheden")
    What's OpenSeek?


    You should use code tags when posting code. Makes it easier to read.

    Code:
    If TempVars("InUitSchakelen") Then    Call modInUitSchakelen(TempVars("Shopbeheerder"), frmnm, Me.ActiveControl.Name, Me.ActiveControl.Caption)
    End If
    This is the code for the actual processing:
    
    
    Public Sub modInUitSchakelen(InUit, frm, ctl, cap)
        On Error GoTo Proc_Error
        DoCmd.Hourglass True
        If InUit = "xxxxxxxx" Then GoTo Proc_Exit
        Dim rs As DAO.Recordset
        Dim db As DAO.Database
        Dim strsql As String
        strsql = "SELECT * FROM FormBevoegdheden WHERE Identificatie = " & Chr(34) & InUit & Chr(34) & " ;"
        Set db = CurrentDb()
        Set rs = db.OpenRecordset(strsql, dbOpenDynaset)
        With rs
            If .RecordCount > 0 Then
                .MoveFirst
                Do Until .EOF
                    Forms(frm).Controls(ctl).BorderColor = vbRed
                    .MoveNext
                Loop
            End If
        End With
        rs.Close
        Set rs = OpenSeek("FormBevoegdheden")
        
        With rs
            .Index = "Primarykey"
            .Seek "=", frm, ctl, InUit
            If .NoMatch Then
                .AddNew
                !Form = frm
                !Control = ctl
                !Identificatie = InUit
                .Update
                Forms(frm).Controls(ctl).BorderColor = vbRed
            Else
                .Delete
                Forms(frm).Controls(ctl).BorderColor = vbBlack
            End If
        End With
    
    
    Proc_Exit:     On Error Resume Next
        rs.Close
        db.Close
        Set rs = Nothing
        Set db = Nothing
        DoCmd.Hourglass False
        Exit Sub
    
    
    Proc_Error:
        If Err.Number = 2220 Then
            Resume Next
        End If
        Call errfout(Err.Number, Err.Description)
        Resume Proc_Exit
    
    
    End Sub
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 07-02-2022, 08:08 PM
  2. Replies: 9
    Last Post: 07-06-2015, 01:47 AM
  3. Replies: 2
    Last Post: 10-31-2012, 11:52 AM
  4. Replies: 2
    Last Post: 06-14-2010, 03:25 PM
  5. query problem i have a problem wi
    By maxx3 in forum Queries
    Replies: 0
    Last Post: 06-29-2009, 02:29 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums