Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6347023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:07:45+00:00 2026-05-24T21:07:45+00:00

I have some weird behavior that has me perplexed. I created a function in

  • 0

I have some weird behavior that has me perplexed. I created a function in vb (Microsoft Word Macro version of VB) which looks like this:

Public Function isitnullorempty(newstring As String) As Boolean
    If IsNull(newstring) Or IsEmpty(newstring) Or newstring = "" Then
        isitnullorempty = False
    Else
        isitnullorempty = True
    End If
End Function

It seems to work as expected if I create a variable and then set it to null, “”, or leaving it empty. I manipulate the variable and then do MSGBOX isitnullorempty(variable) and it echos what I expect. It doesn’t behave the same way when I put a recordset inside the function however. I’ve even tried to make a variable set it to the record set and then test it but that doesn’t work either. If I try to invoke the following

'ADO query code here (This is an ODBC connection)
DO While (Not oRecordset.EOF)
    MsgBox isitnullorempty(oRecordset.Fields("CustomerTypeRefFullName"))

    oRecordset.MoveNext
Loop

This yields the error: Invalid use of Null.

So two fold question.

Is there already a vb function that exists which does what I want?
Why does my code behave this way?

Weirder yet is that if I do the test individually outside of the function, it works.

Temporary Solution

It writes more code than it needs to but since I can’t seem to call the function with the recordset value I will just individually check each record according to my needs like this:

 If IsNull(oRecordset.Fields("CustomerTypeRefFullName").Value) Or IsEmpty(oRecordset.Fields("CustomerTypeRefFullName").Value) Or oRecordset.Fields("CustomerTypeRefFullName").Value = "" Then
    MsgBox "potato"
End If
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:07:46+00:00Added an answer on May 24, 2026 at 9:07 pm

    The answer is if you want to pass a null to a function’s parameter that parameter needs to be set as variant.
    Public Function isitnullorempty(newstring As Variant) As Boolean

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some extremely weird behavior that seems to result in silent exceptions. How
I have a list of links that are exhibiting some really weird behavior. The
I have this exported file of some weird (standard for this industry!) format, which
I have some UI in VB 2005 that looks great in XP Style, but
Alright, I have some weird behavior and this question goes to the people out
I have some weird behaviour in Qt that seems like a defect. I'd like
I am getting some weird behavior when using cout in my programm, which is
I have noticed some weird behavior when sourcing another script within my shell script.
I have stumbled on a weird behavior that I just could not explain at
I am seeing some very weird behavior with a set of ListViews that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.