Solved Set Text to Null after OpenForm Command

EdwardsC

New member
Local time
Today, 12:43
Joined
Jul 10, 2019
Messages
21
I am at a loss in my code and need help identifying where I am going wrong. Basically, I am working between two forms (main and time clock). The employee puts their EmployeeID (Primary) in Text8 Text field on the main form which opens to the associated record in the time clock form. When the timeclock form opens, I want the Text8 field to go null and the timeclock form to still be on on the associated record. However, the timeclock record opens up blank. Below is the code which is not giving me the desired results.

Private Sub Timeclockbtn_Click()
DoCmd.OpenForm "TimeclockF", , , "EmployeeID=" & Text8 & " AND " & _
Me.Text8 = Null
End If
End Sub
 
Private Sub Timeclockbtn_Click()
DoCmd.OpenForm "TimeclockF", , , "EmployeeID=" & Text8 & " AND " & _
"IsNull (TimeOut)"
Me.Text8 = Null
End If
End Sub
 
Try using a variable and assign Text8 to it.
 
Can't compare anything to Null. Use IsNull()>

DoCmd.OpenForm "TimeclockF", , , "EmployeeID=" & Text8 & " AND " & IsNll(Me.Text8)

But criteria makes no sense.

Oh, now I see your second post. Could have edited the first one.

Is Text8 UNBOUND?
 
Last edited:
theDBguy I tried dimensioning a variable and assigned Text8 and the same thing occurs.

When I run the code like this, the field Text8 field goes Null. It's not ideal and requires an extra step but it works if there are any other suggestions?

Private Sub Timeclockbtn_Click()
DoCmd.OpenForm "TimeclockF", , , "EmployeeID=" & Text8 & " AND " & _
"IsNull (TimeOut)"
MsgBox ("EmployeeID is recognized")
Me.Text8 = Null
End If
End Sub
 
can you open the TimeclockF in dialog window?

Private Sub Timeclockbtn_Click()
DoCmd.OpenForm "TimeclockF", , , "EmployeeID=" & Text8 & " AND " & _
"IsNull (TimeOut)",, acDialog
MsgBox ("EmployeeID is recognized")
Me.Text8 = Null
End If
End Sub
 
theDBguy I tried dimensioning a variable and assigned Text8 and the same thing occurs.

When I run the code like this, the field Text8 field goes Null. It's not ideal and requires an extra step but it works if there are any other suggestions?

Private Sub Timeclockbtn_Click()
DoCmd.OpenForm "TimeclockF", , , "EmployeeID=" & Text8 & " AND " & _
"IsNull (TimeOut)"
MsgBox ("EmployeeID is recognized")
Me.Text8 = Null
End If
End Sub
Hmm, what was the name of your variable? I can't see it from the code you posted.
 
Setting a text box to null is probably not as easy as you might like, but you might get away with setting it to a zero-length string.

Me.Text8 = ""

If you do that, comparisons work SO much better. As pointed out earlier, you cannot compare ANYTHING to a null, including another null.
 
Thank you for all of the suggestions. I took arnelgp’s suggestion to open the form in dialog window and it’s working the way I want it too. The field clears!
 

Users who are viewing this thread

Back
Top Bottom