Access - Como asignar un texto a una variable tipo objeto

 
Vista:
sin imagen de perfil

Como asignar un texto a una variable tipo objeto

Publicado por Francisco (7 intervenciones) el 03/06/2021 20:30:27
Hola
Tengo un formulario con varios botones, la idea es que dependiendo el usuario que se firma ponga visible los botones a los que tiene acceso, tengo una tabla con el usuario y el numero de botón.
Mi problema es que para poder realizarlo al nombre del botón le concateno el numero, pero cuando lo asigno me marca error 424 se requiere un Objeto.
De antemano gracias por su ayuda.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Function Permisos()
 
Dim intI As Integer
On Error GoTo Error
 
   Set dbs = CurrentDb
 UsuarioStr = "JOEL"
   sql = "SELECT * FROM permisos WHERE usuario = '" & UsuarioStr & "'"
    Set rst = CurrentDb.OpenRecordset(sql, dbOpenDynaset)
 
   If rst.EOF Then Exit Function
 
   intI = 1
   With rst
      Do Until .EOF
      Dim btn As Object
      Dim bt1 As Object
        btn1 = "[Form_FrmMenuPrincipal].BotónDeNavegación" & !Tarea
        Set btn = [Form_FrmMenuPrincipal].BotónDeNavegación31             ' así si funciona
'       Set btn = btn1                                                ' así no funciona
        btn.Visible = False
         .MoveNext
         intI = intI + 1
      Loop
   End With
 
   rst.Close
 
   Set rst = Nothing
 
   Exit Function
 
Error:
   MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
 
 
End Function
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder