Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    Problema con creazione di una maschera in access

    Ciao a tutti, premetto che non ne capisco tanto di vba... ma mi serve risolvere un problema.
    Ho creato un database in access e ora devo fare alcune maschere. Il problema sta nel creare una maschera di login. Il codice è questo:
    codice:
    Private Sub Interruttore4_Click()
    
    Dim DB As Database 
    Dim SQLStatement1 As String
    Dim SQLStatement2 As String
    Dim rst1 As Recordset
    Dim rst2 As Recordset
    
    If ((IsNull(Testo0.Value) = False) And (IsNull(Testo2.Value) = False)) Then
      Set DB = CurrentDb
      SQLStatement1 = "SELECT * " & _
                      "FROM Amministratore " & _
                      "WHERE codive = '" & Testo0.Value & "';"
      Set rst1 = DB.OpenRecordset(SQLStatement1)
      If (rst1.RecordCount = 0) Then
        MsgBox ("Utente inesistente!")
      Else
        SQLStatement2 = "SELECT password " & _
                        "FROM Amministratore " & _
                        "WHERE codice = '" & Testo0.Value & "';"
        Set rst2 = DB.OpenRecordset(SQLStatement2)
        If (rst2.Fields!Password = Testo2.Value) Then
          DoCmd.Close acForm, "Login"
          MsgBox ("Accesso effettuato.")
        Else
          Testo2.Value = ""
          MsgBox ("Password errata!")
        End If
        rst2.Close
      End If
      rst1.Close
      Set DB = Nothing
    Else
     MsgBox ("Inserire username e password!")
    End If
    
    End Sub
    quando premo sul pulsante mi da l'errore:
    codice:
    Errore di compilazione:
    Previsto tipo definito dall'utente enon progetto
    Quando mi da l'errore evidenzia la scritta in verde nel codice
    Qualcuno sa aiutarmi?
    Il mio Blog
    WbLogIn Free Blog Hosting

  2. #2
    dimenticavo,
    Testo0 e Testo2 sono 2 caselle di testo, mentre Interruttore4 è il pulsante da cliccare..
    Si era capito no?
    Il mio Blog
    WbLogIn Free Blog Hosting

  3. #3
    nessuno sa aiutarmi???
    Il mio Blog
    WbLogIn Free Blog Hosting

  4. #4
    ho lo stesso problema anche io, qualcuno sa come risolvere il problema???

  5. #5
    Utente di HTML.it
    Registrato dal
    Feb 2004
    Messaggi
    121
    Public Function attivazionepass()
    Dim dbs As Database, rst As Recordset, rs As Recordset
    Dim strSQL As String
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("select * from T_Utente where [utente] & [password] =" & "'" & Me![Testo2] & Me![Testo0] & "'", dbOpenDynaset)


    If rst.RecordCount < 1 Then
    MsgBox "ATTENZIONE Utente o Password ERRATA "

    Testo2 = Null
    Testo0 = Null
    Testo2.SetFocus

    Else
    msgbox"Utente abilitato"
    DoCmd.Close acForm, "login", acSaveYes
    DoCmd.OpenForm "tuaForm"


    rst.Edit
    rst.Close
    Set dbs = Nothing

    End If
    End Function

    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''
    in questo modo funziona tutto con semplicità

    saluti
    mila

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.