0

I have a VBA Access userform. In this useform there is a textbox with the name txtSearch_POBOX. I'm trying to get its value using the code below:

Private Sub txtSearch_FirstName_Change()
MsgBox ([Form_Client List].txtSearch_POBOX.Value)
End Sub

But this is constantly returning NULL. When even when there is a value inside the text box. Any ideas?

2 Answers 2

1

Your reference is wrong. It should read:

MsgBox Forms![Client List]!txtSearch_POBOX.Value

As it could be empty, you should use:

MsgBox Nz(Forms![Client List]!txtSearch_POBOX.Value)
Sign up to request clarification or add additional context in comments.

Comments

0

remember that if you want to intercept the text box value while digiting, until you "validate" the content change (e.g. losing focus) the .Value property is not updated.

For instance I used a text box to make a running filter of a submask: I wanted to filter the submask while digiting. To do this you need to use the .Text property.

In the following example I make a running filter of a list of Publishers:

Private Sub txtNameFilter_Change()
On Error Resume Next
    Dim strFilter As String

    If Not IsNull(Me.txtNameFilter.Text) Then
        strFilter = "Publisher LIKE '*" + Me.txtNameFilter.Text + "*'"
        Me.Filter = strFilter
        Me.FilterOn = True
        Me.txtNameFilter.SelStart = Len(Me.txtNameFilter.Text)
    End If
End Sub 

Bye Wiz

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.