By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,478 Members | 1,505 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,478 IT Pros & Developers. It's quick & easy.

Global Variable Help Required!

100+
P: 129
I set a global variable to equal a new password which was the wrong way of doing things, now i have tried many things to get rid of the global variable. All the text evidence has been deleted but it is still functioning. How can i remove or unset the global variable i once declared?
Jul 21 '09 #1
Share this Question
Share on Google+
4 Replies


missinglinq
Expert 2.5K+
P: 3,532
Where are you setting the "global variable to equal a new password?"

What exactly do you mean by "it is still functioning?"

Linq ;0)>
Jul 22 '09 #2

100+
P: 129
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3.     Public g_StaffID As Integer
  4.     Public g_StaffUsername As String
  5.     Public g_StaffPassword As String
  6.     Public g_StaffUserAccessLevel As Byte
  7.     Public g_StaffForename As String
  8.     Public g_StaffSurname As String
  9.  
  10. Public Function Init_Globals()
  11.  
  12.     g_StaffID = ""
  13.     g_StaffUsername = ""
  14.     g_StaffPassword = ""
  15.     g_StaffUserAccessLevel = ""
  16.     g_StaffForename = ""
  17.     g_StaffSurname = ""
  18.  
  19. End Function
  20.  
  21. Public Function get_global(gbl_StaffAccess)
  22.  
  23. Select Case gbl_StaffAccess
  24.  
  25.     Case "g_StaffID"
  26.         get_global = g_StaffID
  27.     Case "g_StaffUsername"
  28.         get_global = g_StaffUsername
  29.     Case "g_StaffPassword"
  30.         get_global = g_StaffPassword
  31.     Case "g_StaffUserAccessLevel"
  32.         get_global = g_StaffUserAccessLevel
  33.     Case "g_StaffForename"
  34.         get_global = g_StaffForename
  35.     Case "g_StaffSurname"
  36.         get_global = g_StaffSurname
  37.  
  38. End Select
  39.  
  40. End Function
This was originally set as a module and the code for the Password Change is as follows;

Dim rstChangePassword As String

Expand|Select|Wrap|Line Numbers
  1.     If IsNull(Me.txtNewPassword) And IsNull(Me.txtConfirmPassword) Then
  2.         rstChangePassword = MsgBox("Please enter a password followed by a verification password to change your old password", vbOKOnly + vbExclamation, "No Password Warning!")
  3.         ElseIf Me.txtNewPassword <> Me.txtConfirmPassword Then
  4.             rstChangePassword = MsgBox("The verification password does not match your New Password, Please retype both", vbCritical + vbOKOnly, "Password Mismatch Warning!")
  5.             Me.txtNewPassword = Null
  6.             Me.txtConfirmPassword = Null
  7.             Me.txtNewPassword.SetFocus
  8.             ElseIf Len(Nz(Me.txtNewPassword.Value)) < 6 Or Len(Nz(Me.txtNewPassword.Value)) > 20 Then
  9.                 rstChangePassword = MsgBox("Please choose a new password that is between 6 and 20 characters long.", vbOKOnly + vbExclamation, "Password Length Warning!")
  10.                 Me.txtNewPassword = Null
  11.                 Me.txtConfirmPassword = Null
  12.                 Me.txtNewPassword.SetFocus
  13.                 ElseIf Len(Nz(Me.txtConfirmPassword.Value)) < 6 Or Len(Nz(Me.txtConfirmPassword.Value)) > 20 Then
  14.                     rstChangePassword = MsgBox("Please choose a new password that is between 6 and 20 characters long.", vbOKOnly + vbExclamation, "Password Length Warning!")
  15.                     Me.txtNewPassword = Null
  16.                     Me.txtConfirmPassword = Null
  17.                     Me.txtNewPassword.SetFocus
  18.                     Else
  19.                         rstChangePassword = MsgBox("Your password has been changed.", vbOKOnly + vbInformation, "Password Change Success!")
  20.                         g_StaffPassword = Me.txtNewPassword
  21.     End If
It worked once but then broken as viewing different passwords set all the value to the same value as the txtNewPassword. I tried deleting all the code for the g_StaffPassword but the problem still exists.
Jul 22 '09 #3

Expert 100+
P: 1,287
Are you persisting these values in your database somewhere, or resetting them every time you open it?
Jul 22 '09 #4

100+
P: 129
I am permitting these values through once logged in but resetting the values ever closure or logout occurs.

Everytime i want to create a NewPassword the CurrentPassword disappears because the BlankNewPassword has focus and the code stated g_StaffPassword = me.txtNewPassword. I should of realised this would not of worked and was a stupid quick method of doing this.

So is there a way i can get rid of any evidence of a global called g_StaffPassword or can i unset what i did?
Jul 22 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.