Una famiglia di sistemi di gestione per database relazionali di Microsoft progettati per semplificare l'uso.
ciao Nicola.
stai impostando la dlookup sul database corrente e non su quello in cui la tabella login risiede.
Credo sia il caso di considerare l'evento form su apertura e non su corrente, ma non so se sto capendo al meglio e sfruttare il recordset per il match.
Ciao, Sandro.
Option Compare Database
Option Explicit
Private Sub Form_Open(Cancel As Integer)
Dim wrk As DAO.Workspace
Dim db As DAO.Database
Set wrk = DBEngine.Workspaces(0)
Const strDBPath As String = "C:\Users\xx\Desktop\Login e Magazzino.accdb"
Set db = wrk.OpenDatabase(strDBPath)
Dim rsSystem As DAO.Recordset
Dim sSQL As String
'sSQL = "SELECT * FROM LOGIN WHERE USER='" & fOSUserName() & "'"
sSQL = "SELECT user FROM LOGIN in '" & strDBPath & "' WHERE USER='" & fOSUserName() & "';"
Set rsSystem = db.OpenRecordset(sSQL, 2) 'dbopendynaset
With rsSystem
.FindFirst "user='" & fOSUserName() & "'"
If Not .NoMatch Then
MsgBox "Success"
Application.FollowHyperlink strDBPath
Else
MsgBox "Utente non abilitato!!", vbInformation, "Contattare l'Amministratore."
End If
.Close
End With
'exitRoutine:
If Not (db Is Nothing) Then
Set rsSystem = Nothing
db.Close
Set db = Nothing
DoCmd.Quit
End If
Set wrk = Nothing
End Sub
ps. per quanto alle Api, sarebbe bene dichiarare con compilazione condizionale anche la modalita' 32 bit.