own passwort function

T

Thomas Sandgruber

Hello NG



I'd like to write a Passwort - function for several different access
applications.



Shout:

In the applications I have a main screen with a Button (BUTTONPW). When the
Button is pressed I call the function PASSWORTQUERY. (event: "When CLICK")



In this routine I call with DOCMD a Userform where the Users has to type in
the passwort.

Afterwards the user can click OK or Exit.
If Exit:

The Userform shoult be closed an the Programm returns to the Main screen



If OK:

The Passwort will be checked. The return should be true or false.



Problem:



After cklicking the button BUTTONPW the Userform comes up to the screen.

Instead of waiting for the the userinput, the programm continues with the
next line after the DOCMD. (look source-code: next line is msgbox)



Wish:

The program should call the passwort - window. The programm should wait
until the user puts in the passwort or presses Exit.



After putting in the passwort it should be checked

If Ok: true should be given back to the function PASSWORTQUERY

ELSE: false should be given back.



PasswortQuery should give this return value to the main screen



Do you have any ideas?



Sub BUTTONPW_CLICK , Dieser Button ist im
Hauptprogramm angelegt

Dim ret as boolean



' Jetzt Aufrufen des Passwortfensters



Ret = passwortabfrage ("TEST")





' Diese Anweisungen sollen solange warten, bis Passwortabfrage beendet ist

Msgbox(ret)

Msgbox("123")

Msgbox ("222")

Usw.



endsub







Function PasswortQuery (pw as string) as boolean

Dim returnwert as boolean



' Show Passwort - Window

Docmd.openform "PasswortInput",,,,,pw



PasswortQuery = returnwert



End function







Routines of the window PasswortInput

Routine: OK-Click



Dim ret as boolean



If passworteingegeben = pw

Ret = true

Else

....

endif







Routine EXIT - Click

PasswortInput.Close
 
G

George Nicholson

DoCmd.OpenForm "PasswortInput",,,,,pw
WaitUntilClosed("PasswortInput",acForm)
.....Code for whatever you want to happen after the Password form is
closed...

**** 2 General Support Functions ****
**** IsLoaded is a standard, with many uses.
**** WaitUntilClosed is just one of them (which is why it is 2 routines, not
1)

Public Sub WaitUntilClosed(strObjName As String, Optional lngObjType As
acObjecttype = acForm)
' Suspends code execution while object is open. Default object is a
Form.
On Error Resume Next
Do While IsLoaded(strObjName, lngObjType)
DoEvents
Loop
End Sub

Public Function IsLoaded(strObjName As String, Optional lngObjType As
acObjecttype = acForm) As Boolean
' Returns True if strName is Open (non-zero), False/0 otherwise.
' Should return 0, not an error, if the object doesn't exist
' Default Object is Form
On Error Resume Next
IsLoaded = (SysCmd(acSysCmdGetObjectState, lngObjType, strObjName) <> 0)
End Function

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top