Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    array value fails on test (Access 2003, XP SP 3)

    <font color=red>Think I figured it out - set NZ output to ""</font color=red>

    what's wrong with this code?

    Dim ArrLongValidates() As Variant
    ReDim ArrLongValidates(1 To 4, 1 To 2)
    Dim i As Integer


    'Validate Form
    Valid = 0

    ArrLongValidates(1, 1) = Me.UE_P1baB.Name
    ArrLongValidates(1, 2) = Nz(Me.UE_P1baB.Value)
    ArrLongValidates(2, 1) = Me.UE_P1bbB.Name
    ArrLongValidates(2, 2) = Nz(Me.UE_P1bbB.Value)
    ArrLongValidates(3, 1) = Me.UE_P1bcB.Name
    ArrLongValidates(3, 2) = Nz(Me.UE_P1bcB.Value)
    ArrLongValidates(4, 1) = Me.UE_T1d.Name
    ArrLongValidates(4, 2) = Nz(Me.UE_T1d.Value)

    For i = 1 To 4

    If ArrLongValidates(i, 2) Is Null Then
    Valid = 1
    End If

    If I run it on some fields on the form with data already entered, it works. i want it to run on the fields specified, with no requirement that data be present.

    Both name and value are text, BTW.

    ??

    TIA

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

    Re: array value fails on test (Access 2003, XP SP 3)

    In the first place, you should use IsNull(...) in VBA code instead of ... Is Null (the latter is correct in SQL).

    In the second place, the result of Nz is never Null (that's the entire purpose of the Nz function), so ArrLongValidates(i, 2) will never be Null. If you want to check whether Me.UE_P1baB.Value is Null, you should *NOT* apply Nz to it.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: array value fails on test (Access 2003, XP SP

    thanks - i tend to forget IsNull test has a different syntax.

Posting Permissions

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