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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clock in/ Clock out 2

Status
Not open for further replies.

Daps89

Technical User
Mar 15, 2011
10
GB
thread702-1579349


Hi,
I want to create a form in Access, where it is possible to clock in and clock out.

The form will contain the fields FirstName, LastName, PurposeOfVisit and the clock in and out fields will be hidden.

The purpose of the form is to log who visited a particular site and log the time in and out on the click of a button.

I tried to use the following code, from another thread:

For the In button:
DoCmd.OpenForm "frmClock", acNormal, , , acFormAdd, acDialog, "In"

For the Out button:
DoCmd.OpenForm "frmClock", acNormal, , , acFormAdd, acDialog, "Out"

For the textbox (the example only had 1 text box)
Dim strInOut as string
If Not IsNull(Me!txtEmpid) Then
strInOut = Forms!frmClock.OpenArgs
If Len(strInOut) > 0 Then
If strInOut = "In" Then
Me!txtIn = Now()
ElseIf strInOut = "Out" Then
Me!txtOut = Now()
End If
End If
End If

When pressing the button an error “invalid use of null” appears?
Does anyone know what is wrong with what I am doing? Or is there another way to accomplish the task?

Thanks
 
Is there a null value in the text box when you press the button?
 

For some reason you are not getting the Args in the below line.

Code:
strInOut = Forms!frmClock.OpenArgs

The workaround would be, Keep a hidden textbox in the form where you are calling frmClock. Fill the value of the textbox based on the button click. ("In", "Out")

Code:
Private Sub cmdIn_Click()
txtType.Value = "In"
DoCmd.OpenForm "frmClock", acNormal, , , acFormAdd, acDialog 
End Sub

Private Sub cmdOut_Click()
txtType.Value = "Out"
DoCmd.OpenForm "frmClock", acNormal, , , acFormAdd, acDialog 
End Sub

Dim strInOut as string
If Not IsNull(Me!txtEmpid) Then    
    'strInOut = Forms!frmClock.OpenArgs
     strInOut = Forms!Form1.txtType
    If Len(strInOut) > 0 Then
        If strInOut = "In" Then
            Me!txtIn = Now()
        ElseIf strInOut = "Out" Then
            Me!txtOut = Now()
        End If
    End If
End If
 
How are ya Daps89 . . .

Try this:
Code:
[blue]   Dim strInOut As String
   
   strInOut = Me.OpenArgs
   
   If Not IsNull(Me!txtEmpid) Then
      If InStr("In~Out", strInOut) > 0 Then
         Me("txt" & strInOut) = Now()
      End If
   End If[/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top