Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2003
    Posts
    74

    Unanswered: check empty field

    hi,

    i have a form that when the user enter the NRIC (PK) , it will display records under this NRIC.

    on this form there is an unbound field. how do i check if there aren't any record diplay, then this field will be empty.

    how can i do that??
    i am not very good with db, recordset......... pls guide me along.

    pls advice
    nono

  2. #2
    Join Date
    Oct 2003
    Location
    São Paulo - Brazil
    Posts
    91

    Re: check empty field

    Originally posted by damnnono_86
    hi,

    i have a form that when the user enter the NRIC (PK) , it will display records under this NRIC.

    on this form there is an unbound field. how do i check if there aren't any record diplay, then this field will be empty.

    how can i do that??
    i am not very good with db, recordset......... pls guide me along.

    pls advice
    nono
    Try the Nz() function.
    My environment: Windows XP/ Access 2000 - Using Microsoft DAO 3.6 Library

  3. #3
    Join Date
    Nov 2003
    Posts
    74
    hi,

    can u give me some guidelines on Nz() function????

    i am not very sure how to do it. any definitions/website that i can take a look. i have gone to search for it but the search results don't really give me good examples.

    pls advice
    nono

  4. #4
    Join Date
    Oct 2003
    Location
    São Paulo - Brazil
    Posts
    91
    Originally posted by damnnono_86
    hi,

    can u give me some guidelines on Nz() function????

    i am not very sure how to do it. any definitions/website that i can take a look. i have gone to search for it but the search results don't really give me good examples.

    pls advice
    nono
    Nz(x) returns 0 if x=Null

    It may be used like this:

    If Nz( myVar ) = 0 then
    ... your code --> myVar is Null
    endif
    My environment: Windows XP/ Access 2000 - Using Microsoft DAO 3.6 Library

  5. #5
    Join Date
    Nov 2003
    Posts
    74
    hi,

    what does myVar stands for???
    no of records???


    but i am using the below method, can the code u teach me still be use in my scenario????


    me.recordsource = "SELECT .......... "

    **the code u taught me.
    If Nz(myVar) = 0 Then
    '... your code --> myVar is Null

    End If


    pls advice
    nono

  6. #6
    Join Date
    Oct 2003
    Location
    São Paulo - Brazil
    Posts
    91
    Originally posted by damnnono_86
    hi,

    what does myVar stands for???
    no of records???


    but i am using the below method, can the code u teach me still be use in my scenario????


    me.recordsource = "SELECT .......... "

    **the code u taught me.
    If Nz(myVar) = 0 Then
    '... your code --> myVar is Null

    End If


    pls advice
    nono
    No, you can´t use. Nz() ckecks if a variable has a null value.

    Whent u want to ckeck if a recordset is empty, u should check the "end of file" (EOF) condittion.
    My environment: Windows XP/ Access 2000 - Using Microsoft DAO 3.6 Library

  7. #7
    Join Date
    Nov 2003
    Posts
    74
    can u give me an example???

    nono

  8. #8
    Join Date
    Oct 2003
    Location
    São Paulo - Brazil
    Posts
    91
    Originally posted by damnnono_86
    can u give me an example???

    nono
    Dim rs as ADODB.Recordset
    Set rs = new recordset

    With rs
    .CursorType = adOpenForwardOnly
    .LockType = adLockOptimistic
    .Source = "SELECT * FROM yourTable"
    .Open , CurrentProject.Connection
    .Movenext

    if .EOF = true then
    msgbox "This RecordSet is empty"
    endif

    .close
    end with

    set rs= nothing
    My environment: Windows XP/ Access 2000 - Using Microsoft DAO 3.6 Library

  9. #9
    Join Date
    Nov 2003
    Posts
    74
    hi,

    thanks, your method really works! bravo!!!

    cheers
    nono

Posting Permissions

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