IsNull Problem?

robben

Registered User.
Local time
Yesterday, 16:13
Joined
Jan 27, 2008
Messages
52
I have the following code which determines whether the field is blank or if there is an empty string. (see below)

If IsNull(Me.myTextBox) Or Me.myTextBox = "" Then
' DO SOMETHING

However, when the code runs I get the following error: "Run-time error '438' "Object doesn't support this property or method".

I have no clue what I'm doing wrong.

Would anyone have any suggestions?

Thanks
 
I dont think this error is pertaining to this line... What is your full code?

Please use [ code ] and [/ code ] tags around your code when you post it (without the spaces offcourse)
 
If you are getting this error the IDE generally highlights the offending code or code word.

Do you actually have a TextBox on the Form named myTextBox?
Are you actually running this from a Form code Module or is it from a Database Code Module?

Try:

If Len(Nz(Me.myTextBox, "") > 0 Then

.
 
Thank you for your reply, please see the function code. Basically the function attempts to open a word file therefore it checks that it has the filename before it attempts to open it.
Code:
Private Sub OpnFrm680Btn_Click()
     'Check to see that there is a document file path associated with the record
     If IsNull(Me.MyTxtBx) Or Me.MyTxtBx = " " Then
        MsgBox "Please Ensure There Is A File Path Associated " & _
        "For This Document", _
               vbInformation, "Action Cancelled"
        Exit Sub
    Else
        'Check that the document specified in the file path is actually there
        If (Dir(Me.MyTxtBx) = "") Then
           MsgBox "Document Does Not Exist In The Specified Location", _
                  vbExclamation, "Action Cancelled"
            Exit Sub
        Else
            'Opens document in Word
            Call OpenWordDoc(Me.MyTxtBx)
        End If
    End If
    
End Sub
Sub OpenWordDoc(strDocName As String)
  
   Application.FollowHyperlink strDocName
    
End Sub
 
* When I run the code it hightlights the line I've shown in the first message.

* Textbox exists as when I write Me. the textbox appears

* If i take all the code out of the function it runs ok so its not some other code elsewhere which is causing the problem, so this is confusing me.

--------------------------------------------------------------
I have tried writting: If IsNull(Me.Frm680TxtBx) then
and: If Me.Frm680TxtBx = " " Then
but they both fail.
--------------------------------------------------------------
 
Last edited:
yes namliam, thats what I thought even though I very little knowledge of VBA.
It just seems to not like the first line.
I've had this function working on other apps and it runs ok.
 
Try Deleting the Text Box and installing a new one.

Also, for the heck of it try:

If IsNull(Forms("yourFormName").MyTxtBx) = True Then

.
 
Got it working now. Seems strange I just deleted it and added it again.
 
Be warned:

This is now a good indication that you should Backup your project and put it in a safe place.

.
 

Users who are viewing this thread

Back
Top Bottom