Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Feb 2001
    Location
    Torn between Kent & Essex, England
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    invalid use of null (AC 2K)

    I'm trying to trap out if a user has not entered all required information on a form by using

    strOutFileName = Me![fldWorklistFileName]
    If strOutFileName = "" Or " " Then
    cmdBrowse2_Click
    Exit Sub
    End If

    but I get "invalid use of null" error on the first line.

    I've tried also with
    strOutFileName = CStr(Me![fldWorklistFileName])
    but to no avail.

    Any thoughts?

    Gavin

  2. #2
    3 Star Lounger
    Join Date
    Jun 2001
    Location
    Maidstone, Kent, England
    Posts
    398
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: invalid use of null (AC 2K)

    Try checking for nulls with the isnull function

    If Isnull(Me![fldWorklistFileName]) Then
    cmdBrowse2_Click
    Exit Sub
    End If

    HTH

    Peter

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: invalid use of null (AC 2K)

    You must either check IsNull(Me![fldWorklistFileName]) before assigning it to strOutFileName (for you can't assign a Null value to a string), or use

    strOutFileName = Nz(Me![fldWorklistFileName], "")

    The Nz function replaces Null values by the value specified in the second argument.

  4. #4
    Lounger
    Join Date
    Feb 2001
    Location
    Torn between Kent & Essex, England
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: invalid use of null (AC 2K)

    Using

    strOutFileName = Nz(Me![fldWorklistFileName], "")
    If strOutFileName = "" Or " " Then
    MsgBox "You must enter a valid file name first!", vbCritical
    cmdBrowse1_Click
    Exit Sub
    End If

    but I get a type mismatch on the second line if strOutFileName has a real, string value in it.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: invalid use of null (AC 2K)

    The line

    If strOutFileName = "" Or " " Then

    is wrong - I should have noticed this before. Replace it with

    If strOutFileName = "" Or strOutFileName = " " Then

    If this doesn't solve the problem, post back.

  6. #6
    Lounger
    Join Date
    Feb 2001
    Location
    Torn between Kent & Essex, England
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: invalid use of null (AC 2K)

    I should have noticed too! Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •