Passing Arguements between forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to pass arguements between forms and I have been trying to do
this using a class module. I have a Let and Get procudure in the class
module. I use the "let" in one form and then try to "get" it in another
form, but it doesn't work. What can I do?
 
Can you give us an example of the code you are using?

the Let , get , and how do you assign the values
 
This is the code in my class:
-----
Option Compare Database
Option Explicit

Private strUserID As String

Public Property Let UserId(strParam As String)
strUserID = strParam
End Property

Public Property Get UserId() As String
UserId = strUserID
End Property
----

This is the code in form that sets the UserId:
----
Private Sub btnLogin_Click()
Dim objTest As Test
Dim str As String
Dim str2 As String
Dim authentication As Boolean
Dim db As Database
Dim myTime As Date
Dim myDate

Set objTest = New Test
Set db = CurrentDb()

'Check to see if the user has a valid id
If checkCredentials(Me.txtUserID.Value, Me.txtPassword.Value) = False Then
'If the user doesn't have a valid id display message
If MsgBox("The User ID or Password specified are invalide, please try
again!", vbOKOnly, "Login Error") = vbOK Then

End If
Else
'Else check to see if the user is working, if the user is working
'Set the class variable and then open the Clock Out Form
If currentlyWorking(Me.txtUserID.Value) = True Then
objTest.UserId = Me.txtUserID.Value
DoCmd.OpenForm ("Clock_Out_Form")
DoCmd.Close acForm, "Login_Form"
Else
'If the user is not clocked in, clock them in
myTime = time
myDate = Date
time = dhRoundTime(myTime, 15)
str = "insert into work_performed (user_id, event, clock_in_time,
clock_in_date, clock_out_time, clock_out_date, total_time_for_session) values
('" & Me.txtUserID.Value & "', 'null', '" & time & "', '" & myDate & "',
'null', null, 'null');"
db.Execute str

str2 = "update user_information set work_status='t' where user_id='"
& Me.txtUserID.Value & "';"
db.Execute str2

Me.txtUserID.Value = Null
Me.txtPassword.Value = Null

End If

End If

End Sub
----

This is the code that tries to get the UserID:
----
Private Sub btnClockOut_Click()
Dim objTest As Test
Dim db As Database
Dim SQLstr1 As String
Dim SQLstr2 As String
Dim myTime As Date
Dim myDate
Dim user As String

'Set Database, time, and date
Set db = CurrentDb()
myTime = time
myDate = Date

'Set new object and user string to UserId contained in class module
Set objTest = New Test
user = objTest.UserId
'SQL statement to update table work_performed
SQLstr1 = "update work_performed set event='" & Me.cmbActivity & "',
clock_out_time='" & dhRoundTime(myTime, 15) & "', clock_out_date='" & myDate
& "' where user_id='" & user & "' and event='null';"
db.Execute SQLstr1

calculateTotalTimeForSession (user)

SQLstr2 = "update user_information set work_status='f' where user_id='" &
user & "';"
db.Execute SQLstr2

DoCmd.Close acForm, "Clock_Out_Form"
DoCmd.OpenForm ("Login_Form")

End Sub
----
 
Back
Top