Discussion:
Null value from text box
(too old to reply)
NeoFax
2010-08-27 12:38:12 UTC
Permalink
Me.txtMaterial is not grabbing the actual text string from the text
box. When I step thru the code,
Me.txtMaterial is Null. Why is it not grabbing the txtMaterial info?

Private Sub txtMaterial_KeyDown(KeyCode As Integer, Shift As Integer)
fltrInfo = ""
fltrMaterial = Null
fltrMaterial = Me.txtMaterial

If KeyCode = 13 Then
If IsNull(Me.lstPlant) Then
fltrInfo = "(((tblMaterial.Material) Like '" & fltrMaterial &
"'))"
Else
fltrInfo = "(([tblMaterial].[Material] Like '" & fltrMaterial
& "')) AND ([tblMaterial].[Plnt]='" & Me.lstPlant & "')"
End If

DoCmd.OpenForm "frmAllMaterial", acNormal, , fltrInfo
End If
End Sub
Ken Snell
2010-08-31 01:38:00 UTC
Permalink
Using the KeyDown event does not let the texbox update its value before your
code runs, so therefore Me.txtMaterial will not have a value when your code
runs. Why are you using this event to run your code? What is it you're
trying to do?
--
Ken Snell
http://www.accessmvp.com/KDSnell/
Post by NeoFax
Me.txtMaterial is not grabbing the actual text string from the text
box. When I step thru the code,
Me.txtMaterial is Null. Why is it not grabbing the txtMaterial info?
Private Sub txtMaterial_KeyDown(KeyCode As Integer, Shift As Integer)
fltrInfo = ""
fltrMaterial = Null
fltrMaterial = Me.txtMaterial
If KeyCode = 13 Then
If IsNull(Me.lstPlant) Then
fltrInfo = "(((tblMaterial.Material) Like '" & fltrMaterial &
"'))"
Else
fltrInfo = "(([tblMaterial].[Material] Like '" & fltrMaterial
& "')) AND ([tblMaterial].[Plnt]='" & Me.lstPlant & "')"
End If
DoCmd.OpenForm "frmAllMaterial", acNormal, , fltrInfo
End If
End Sub
NeoFax
2010-09-01 19:45:46 UTC
Permalink
I fixed it to work. Had to add .value to the end. What I am trying
to do is filter a second form based off of a part number the user
type's in the text box and do not want the user to type and then click
a button.

Loading...