Reputation: 212
Basically It's a login form and i'm trying to save the ID which is the Me.CBOUsername.Column(0) but I get an error when i try to call it in another form.
Option Compare Database
Option Explicit
Public ID_ As String
Private Sub Command4_Click()
Dim strCBOPass As String
Dim strPassword As String
strCBOPass = Me.CBOUsername.Column(1)
strPassword = Me.txtpassword
If strCBOPass = strPassword Then
MsgBox "Login Successful!"
DoCmd.OpenForm "Form1"
DoCmd.Close acForm, Me.Name
ID_ = Me.CBOUsername.Column(0)
Else
MsgBox "login Unsuccessful!"
End If
End Sub
Upvotes: 3
Views: 1029
Reputation: 1077
It may be a little easier to explain this way.
As an example of a global variable:
Public Global_Variable1 as String
Public Sub Procedure1()
Global_Variable1 = "Test"
End Sub
Public Sub Procedure2()
Call Procedure1
MsgBox (Global_Variable1) 'return Test
End Sub
Add the module by right-clicking, and using Insert > Module
Upvotes: 3