Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing variables-halting code 1

Status
Not open for further replies.

mickier

Programmer
Jul 5, 2001
17
US
I need some help passing variables.
First. I do not have my database Protected using Access Security.

I have a MAIN form that has about 20 different fields that will have to be "signed off" by various people, so I need field-level security.
I have some code in a MAIN form (on entrance to a field)that says: When someone tries to enter, open the form PASSWORD. In the PASSWORD FORM I have the string that is typed in assigned to a variable X and then close the password form on OK click. Now, back to the code in the MAIN form---
I have a statement: If variable X = the assignedpassword, then allow access to this field, otherwise give nastygram message. However, the code just runs through without stopping. The code evaluates the variable before the person has had a chance to enter in the password on the password form and automatically executes the FAIL code. How do I stop it or make it pause and then restart after the person is done typing their password?

Or, am I going about this completely wrong. (Input box works but you can see the password that is typed in--I want ****s)
Thanks.
 
open the password form as acDialog.. it must be close prior to any other code processing

DoCmd.OpenForm "Form Name", , , , , acDialog


PaulF
 
Oh my God. Is it THAT easy?
Man, I'm gonna kick myself in the knee!

I guess, it's all in what you have experienced...

THANKS!
 
ARG. It is now halting but Now I can't get the variable to pass back to the main form. Here is my code.

Private Sub SignAllreq_Click()
Dim mypass As String
DoCmd.RunMacro "masssignI"

'a macro that opens the
'Password form in dialog mode.
'password form has a command (on close) that
'assigns mypass=forms!password.password
'a msgbox shows this assignment is working

MsgBox (mypass)
'this is showing BLANK!
'the MYPASS variable is not coming over
'from the password form--why?
If mypass = "chicken" Then
Beep
Me.ReqQAsign = QA
Me.ReqPEsign = PE
Me.ReqPMsign = PM
Me.ReqRDsign = RD
Me.ReqHSEsign = HSE
Me.ReqMatsign = Mat
Me.Reqfinsign = Fin
Me.ReqQAsigndate = Now()
Me.ReqPEsigndate = Now()
Me.ReqPMsigndate = Now()
Me.ReqRDsigndate = Now()
Me.ReqHSEsigndate = Now()
Me.ReqMatsigndate = Now()
Me.Reqfinsigndate = Now()
Me.Concerns.SetFocus
Else
MsgBox "ACCESS DENIED!!!", vbOKOnly, "FAIL!": Forms![main]!Concerns.SetFocus
End If
End Sub
 
one way to get the Data passed back to the Main Form is to make your variable mypass a Public variable. Declare it in a Module (under the Module Tab, not behind a Form)
Public mypass As String

another method would be to save the value to a table, then open the table from the Main Form and check the value.

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top