IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

IHM Discussion :

Passer une variable pour un état


Sujet :

IHM

  1. #1
    Membre régulier
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Juin 2008
    Messages
    161
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Juin 2008
    Messages : 161
    Points : 86
    Points
    86
    Par défaut Passer une variable pour un état
    Bonjour, j'ai une petite question, j'avoue que je n'ai pas encore beaucoup cherché mais vu que c urgent je poste et je cherche en même temps.

    J'ai créer une "mini application access" et 2 problèmes se pose.
    Mon application est accessible en 2 mode, Administrateur soit tout est visible et le 2e en mode utilisateur où il ne pourrait qu'acceder à sa fiche de poste client qui est un état.
    Je voudrait savoir comment faire pour renvoyer une réponse a une messagebox qui s'ouvre pour un état car j'ai mon code sql qui indique une variable suivante :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SELECT T_POSTE.*, T_PERSONNEL.perso_service FROM T_POSTE INNER JOIN T_PERSONNEL ON T_POSTE.id_poste=T_PERSONNEL.perso_poste WHERE T_POSTE.id_poste=id;
    [IMG][/IMG][IMG][/IMG]

    Et je voudrait renvoyer automatiquement cette valeur, c'est a dire qu'au moment où l'utilisateur se log il recupère l'id qui remplacerai ma variable "id" de son poste dans ma base et le renvoi pour l'affichage de son propre poste, c'est a dire qu'il ne peut voir que son poste à lui.
    Le 2e problème qui revient au même c'est quand je suis sur mon formulaire POSTE j'ai donc l'affichage des info du poste de mon client et je voudrai y inserer un bouton qui me crée l'état pour le poste visualisé seulement.

    Merci de votre aide

  2. #2
    Rédacteur/Modérateur

    Avatar de Jean-Philippe André
    Homme Profil pro
    Architecte Power Platform, ex-Développeur VBA/C#/VB.Net
    Inscrit en
    Juillet 2007
    Messages
    14 628
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : Canada

    Informations professionnelles :
    Activité : Architecte Power Platform, ex-Développeur VBA/C#/VB.Net
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2007
    Messages : 14 628
    Points : 34 329
    Points
    34 329
    Par défaut
    salut,
    tu peux regarder les possibilités qu'offrent les tables de paramètres pour gérer ce genre de cas : http://jpcheck.developpez.com/tutori...es-initiation/
    tu pourrais ainsi remplacer ta clause
    Code SQL : Sélectionner tout - Visualiser dans une fenêtre à part
    WHERE T_POSTE.id_poste=id;
    par une mouture du style
    Code SQL : Sélectionner tout - Visualiser dans une fenêtre à part
    WHERE T_POSTE.id_poste=GetParam('id');

    Bonne lecture
    Cycle de vie d'un bon programme :
    1/ ça fonctionne 2/ ça s'optimise 3/ ça se refactorise

    Pas de question technique par MP, je ne réponds pas

    Mes ouvrages :
    Apprendre à programmer avec Access 2016, Access 2019 et 2021

    Apprendre à programmer avec VBA Excel
    Prise en main de Dynamics 365 Business Central

    Pensez à consulter la FAQ Excel et la FAQ Access

    Derniers tutos
    Excel et les paramètres régionaux
    Les fichiers Excel binaires : xlsb,

    Autres tutos

  3. #3
    Membre régulier
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Juin 2008
    Messages
    161
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Juin 2008
    Messages : 161
    Points : 86
    Points
    86
    Par défaut
    Désolé pour ma réponse tardive, j'ai réussi pour 1 de mes question à résoudre le problème, ci joint ma solution :
    - Pour l'état : - Pour le code au clic sur mon bouton imprimer (création de mon état) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    Private Sub Print_etat_Click()
    On Error GoTo Err_Print_etat_Click
     
        Dim stDocName As String
     
        stDocName = "POSTE"
        DoCmd.OpenReport stDocName, acPreview, , "id_poste =" & Me.id_poste
     
    Exit_Print_etat_Click:
        Exit Sub
     
    Err_Print_etat_Click:
        MsgBox Err.Description
        Resume Exit_Print_etat_Click
     
    End Sub
    Merci de ton aide.

    Mais mon 2e problème est toujours là, voici ma chaine de connexion, je souhaiterai récuperer la valeur d'un champ dans la même table.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    38
    39
    40
    41
    42
    Private Sub Commande79_Click()
    Me.Requery
     
    Dim sql As String
    Dim rs As DAO.Recordset
    Dim admin
    Dim stDocName As String
     
    Static i As Byte
     
    sql = "SELECT T_PERSONNEL.PERSO_LOGIN,T_PERSONNEL.PERSO_PASSW,T_PERSONNEL.PERSO_ADMIN,T_PERSONNEL.PERSO_POSTE,T_POSTE.ID_POSTE FROM T_PERSONNEL,T_POSTE WHERE T_PERSONNEL.PERSO_LOGIN = '" & Me.login & "' AND T_PERSONNEL.PERSO_PASSW ='" & Me.passwd & "';"
     
    Set rs = CurrentDb.OpenRecordset(sql)
     
    If Not rs.EOF Then
        If rs("PERSO_ADMIN") = True Then
            MsgBox "Accès administrateur autorisé ", vbInformation, "Connexion"
            DoCmd.OpenForm "FRM_MENU_GENERAL ", acNormal, , , , acWindowNormal
            DoCmd.Close acForm, "FRM_CONNEXION"
     
        Else
            MsgBox "Accès en mode utilisateur autorisé ", vbInformation, "Connexion"
            ' A modifier par rapport PC utilisateur
     
            stDocName = "POSTE"
            DoCmd.OpenReport stDocName, acPreview, , "id_poste=" & rs("id_poste")
            MsgBox id_poste, vbInformation, "Connexion"
     
            'DoCmd.Close acForm, "FRM_CONNEXION"
        End If
     
    Else
    MsgBox "(Identifiant, Mot de Passe) incorrect ", vbInformation, "Connexion"
    i = i + 1
    End If
     
    If i = 3 Then
    MsgBox "Vous avez dépassé le nombre de tentatives autorisés", vbCritical
    DoCmd.Quit
    End If
     
    End Sub
    En gros donc je me connecte donc vérification concordance login + password et si ok je voudrai l'ouverture d'un report donc celui précédement expliqué en passant la variable id_poste qui coinciderai avec l'utilisateur connecté.
    Merci de votre aide

  4. #4
    Membre régulier
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Juin 2008
    Messages
    161
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Juin 2008
    Messages : 161
    Points : 86
    Points
    86
    Par défaut
    Après pas mal d'arrachage de cheveux j'arrive petit à petit à mon attente, mais maintenant je bloque sur le test d'une valeur null, voici mon code.
    Dans le contexte, mon premier utilisateur a bien un poste d'attribuer à son nom donc je récupère bien son ID mais le 2e n'en à pas donc a comme valeur NULL mais j'ai message d'erreur à chaque fois.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    Private Sub Commande79_Click()
    Me.Requery
     
    Dim sql As String
    Dim rs As DAO.Recordset
    Dim admin
    Dim stDocName As String
    Dim poste As Long
    Dim MyCheck
     
    Static i As Byte
     
    sql = "SELECT T_PERSONNEL.PERSO_LOGIN,T_PERSONNEL.PERSO_PASSW,T_PERSONNEL.PERSO_ADMIN,T_PERSONNEL.PERSO_POSTE,T_POSTE.ID_POSTE FROM T_PERSONNEL,T_POSTE WHERE T_PERSONNEL.PERSO_LOGIN = '" & Me.login & "' AND T_PERSONNEL.PERSO_PASSW ='" & Me.passwd & "';"
     
    Set rs = CurrentDb.OpenRecordset(sql)
     
    If Not rs.EOF Then
        If rs("PERSO_ADMIN") = True Then
            MsgBox "Accès administrateur autorisé ", vbInformation, "Connexion"
            DoCmd.OpenForm "FRM_MENU_GENERAL ", acNormal, , , , acWindowNormal
            DoCmd.Close acForm, "FRM_CONNEXION"
     
        Else
            'MsgBox "Accès en mode utilisateur autorisé ", vbInformation, "Connexion"
     
            poste = rs("PERSO_POSTE")
     
            If poste = Null Then
                MsgBox "Pas de fiche disponible", vbInformation, "Connexion"
            Else
                stDocName = "POSTE"
                DoCmd.OpenReport stDocName, acPreview, , "id_poste =" & poste
                MsgBox poste, vbInformation, "Connexion"
     
                'DoCmd.Close acForm, "FRM_CONNEXION"
            End If
        End If
     
    Else
    MsgBox "(Identifiant, Mot de Passe) incorrect ", vbInformation, "Connexion"
    i = i + 1
    End If
     
    If i = 3 Then
    MsgBox "Vous avez dépassé le nombre de tentatives autorisés", vbCritical
    DoCmd.Quit
    End If
     
    End Sub
    C'est sur cette partie là que je galère :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    poste = rs("PERSO_POSTE")
     
            If poste = Null Then
                MsgBox "Pas de fiche disponible", vbInformation, "Connexion"
            Else
    car ca me renvoi la valeur null et du coup blocage pour le déroulement du test.
    Merci de votre aide

  5. #5
    Membre régulier
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Juin 2008
    Messages
    161
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Juin 2008
    Messages : 161
    Points : 86
    Points
    86
    Par défaut
    Force est de persévérance, solution trouvé, merci à mes méninge lol
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    38
    39
    40
    41
    42
    Private Sub Commande79_Click()
    Me.Requery
    
    Dim sql As String
    Dim rs As DAO.Recordset
    Dim admin
    Dim stDocName As String
    Dim poste
    Static i As Byte
    
    sql = "SELECT T_PERSONNEL.PERSO_LOGIN,T_PERSONNEL.PERSO_PASSW,T_PERSONNEL.PERSO_ADMIN,T_PERSONNEL.PERSO_POSTE,T_POSTE.ID_POSTE FROM T_PERSONNEL,T_POSTE WHERE T_PERSONNEL.PERSO_LOGIN = '" & Me.login & "' AND T_PERSONNEL.PERSO_PASSW ='" & Me.passwd & "';"
    
    Set rs = CurrentDb.OpenRecordset(sql)
    
    If Not rs.EOF Then
        If rs("PERSO_ADMIN") = True Then
            MsgBox "Accès administrateur autorisé ", vbInformation, "Connexion"
            DoCmd.OpenForm "FRM_MENU_GENERAL ", acNormal, , , , acWindowNormal
            DoCmd.Close acForm, "FRM_CONNEXION"
        Else
            If IsNull(rs.Fields("PERSO_POSTE")) Then
                MsgBox "Pas de fiche disponible", vbInformation, "Connexion"
            Else
                poste = rs("perso_poste")
                MsgBox "Accès en mode utilisateur autorisé ", vbInformation, "Connexion"
                stDocName = "POSTE"
                DoCmd.OpenReport stDocName, acPreview, , "id_poste =" & poste
                MsgBox poste, vbInformation, "Connexion"
            End If
        End If
    
    Else
    MsgBox "(Identifiant, Mot de Passe) incorrect ", vbInformation, "Connexion"
    i = i + 1
    End If
    
    If i = 3 Then
    MsgBox "Vous avez dépassé le nombre de tentatives autorisés", vbCritical
    DoCmd.Quit
    End If
    
    End Sub

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [SQLITE] passer une variable pour ma table
    Par Kexian_ dans le forum Général Python
    Réponses: 4
    Dernier message: 13/04/2012, 18h57
  2. comment passer une variable vb6 à un état crystal report
    Par sehing7 dans le forum VB 6 et antérieur
    Réponses: 1
    Dernier message: 05/04/2012, 13h27
  3. Fonctions setappdata et getappdata pour passer une variable dans 2 gui
    Par mihaispr dans le forum Interfaces Graphiques
    Réponses: 2
    Dernier message: 02/05/2009, 14h55
  4. Problême pour passer une variable dans un SelectCommand
    Par Thetonio007 dans le forum ASP.NET
    Réponses: 12
    Dernier message: 26/06/2007, 14h37
  5. Réponses: 9
    Dernier message: 16/02/2007, 15h10

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo