OVH Cloud OVH Cloud

ouvrir nouvelle fenetre access avec mdw

2 réponses
Avatar
Loutox
Salut à tous,

Soient 2 bases bd1 et bd2 securisées avac un fichier .mdw

l'utilisateur(access et non windows) userX/passwordX est connecté à bd1 qui
est ouverte.

voici ce que je cherche à faire
je souhaiterais, par code, ouvrir une nouvelle instance d'access avec bd2,
en utilisant l'identification de userX (celui qui est connecté à BD1)
et ceci sans ecrire le mot de passe dans le code .

savez vous si cela est possible ?

bonne journée
loutox.

2 réponses

Avatar
Charles ERNST
Si vous ouvrez la bd2 dans le même workspace que la bd1, il n'y a pas de
problème.

ci-joint un bout de code pour ouvrir le formulaire strForm de la base strMDB

'Code Courtesy of'Dev Ashish'
Private Declare Function apiSetForegroundWindow Lib "user32" Alias
"SetForegroundWindow" (ByVal hwnd As Long) As Long
Private Declare Function apiShowWindow Lib "user32" Alias "ShowWindow"
(ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_MAXIMIZE = 3
Private Const SW_NORMAL = 1

Function fOpenRemoteForm(strMDB As String, strForm As String, Optional
intView As Variant) As Boolean
Dim objAccess As Access.Application
Dim lngRet As Long
On Error GoTo fOpenRemoteForm_Err
If IsMissing(intView) Then intView = acViewNormal
If Len(Dir(strMDB)) > 0 Then
Set objAccess = New Access.Application
With objAccess
lngRet = apiSetForegroundWindow(.hWndAccessApp)
lngRet = apiShowWindow(.hWndAccessApp, SW_NORMAL)
'the first call to ShowWindow doesn't seem to do anything
lngRet = apiShowWindow(.hWndAccessApp, SW_NORMAL)
.OpenCurrentDatabase strMDB
.DoCmd.OpenForm strForm, intView
Do While Len(.CurrentDb.Name) > 0
DoEvents
Loop
End With
End If
fOpenRemoteForm_Exit:
On Error Resume Next
objAccess.Quit
Set objAccess = Nothing
Exit Function
fOpenRemoteForm_Err:
fOpenRemoteForm = False
Select Case Err.Number
Case 7866:
'mdb is already exclusively opened
MsgBox "The database you specified " & vbCrLf & strMDB & _
vbCrLf & "is currently open in exclusive mode. " & vbCrLf _
& vbCrLf & "Please reopen in shared mode and try again", _
vbExclamation + vbOKOnly, "Could not open database."
Case 2102: 'form doesn't exist
MsgBox "The Form '" & strForm & _
"' doesn't exist in the Database " _
& vbCrLf & strMDB, _
vbExclamation + vbOKOnly, "Form not found"
Case 7952: 'user closed mdb fOpenRemoteForm True
Case Else:
MsgBox "Error#: " & Err.Number & vbCrLf & Err.Description, _
vbCritical + vbOKOnly, "Runtime error"
End Select
Resume fOpenRemoteForm_Exit
End Function

'************ Code End *************





"Loutox" a écrit dans le message de
news:410e18e4$0$3925$
Salut à tous,

Soient 2 bases bd1 et bd2 securisées avac un fichier .mdw

l'utilisateur(access et non windows) userX/passwordX est connecté à bd1
qui

est ouverte.

voici ce que je cherche à faire
je souhaiterais, par code, ouvrir une nouvelle instance d'access avec bd2,
en utilisant l'identification de userX (celui qui est connecté à BD1)
et ceci sans ecrire le mot de passe dans le code .

savez vous si cela est possible ?

bonne journée
loutox.






Avatar
Loutox
| 'Code Courtesy of'Dev Ashish'

Le fameux !

eh bien c'est parfait, je vais tester ça dès demain matin.

merci beaucoup et bonne soirée.