make a variable go from one form to another

  • Thread starter Thread starter Wes McCaslin
  • Start date Start date
W

Wes McCaslin

I have a login form that runs off of a access database. When you type in the
username and password it will use that information in the select query it
pulls all the information in that record. It will put a number in a
invisible textbox in the login form. Then it runs a if then statment to see
what the number in the textbox is. I was wondering if there is a way to make
that number stay in a varible so you can go back and use that same number on
another form.

Thank you
 
Hey Wes try this,

Module MyGroovyModule

Public UserCreds As New UserDetails ' Establish your User Credential
object

Sub main()
Dim Login As New frmLogin
Application.Run(Login)
' Code in your login form might look like
' ... get userid
' UserCreds.UserID = iUserID
' Code in your Query might look something like;
' Select * from foo where User_ID = UserCreds.UserID
End Sub

End Module

Class UserDetails

Private m_User_ID As Integer = 0
Property UserID() As Integer
Get
Return m_User_ID
End Get
Set(ByVal Value As Integer)
If m_User_ID = 0 Then ' In effect make this a write once read
many
m_User_ID = Value ' Set your value
End If
End Set
End Property

' You can add other items here for ready reference such as access level
:o

End Class

HTH,
 
Back
Top