Results 1 to 7 of 7

Thread: Popup Message

  1. #1
    Join Date
    Oct 2004
    Location
    In cousin's house
    Posts
    303

    Unanswered: Popup Message

    I have an app build from vb6. Pls see details below..

    Rs.Open "Select * from table where field1='0001',cn

    What I want here is If rs has no record found it popup a message. With out using a Rs.recordcount. What I supposed to do? Otherwise if rs has a record I put it into the msflexgrid.

    Pls. help me.
    Last edited by popskie; 01-29-05 at 03:44.

  2. #2
    Join Date
    Feb 2004
    Posts
    59
    I only have used this when using the "Seek" command in relation to a recordset, but I think it may work for you too:

    If rs.NoMatch Then
    MsgBox "No Match", vbokonly + vbexclamation, "No Match Found"
    Else
    'other
    End If
    -Matt H-
    www.comperfection.com

  3. #3
    Join Date
    Oct 2004
    Location
    In cousin's house
    Posts
    303
    Thank mats but I can not find any nomatch statement.
    Last edited by popskie; 01-30-05 at 21:28.

  4. #4
    Join Date
    Dec 2004
    Location
    Laguna, Philippines
    Posts
    147
    pre,

    why dont use recordcount instead? is your recordcount returns -1?
    Regarding to your question, try...

    if rs.eof then 'no record exists..
    'put codes here...
    else 'record exists...
    'put codes here...
    end if
    Give me a place to code and i shall move the earth!

  5. #5
    Join Date
    Oct 2004
    Location
    In cousin's house
    Posts
    303
    Pre,

    We all knew that recordcount is time consuming specially on large table and EOF statement I already used this one, I asked this question try to find out if there is another way beside EOF and recordcount?

    Popskie

  6. #6
    Join Date
    Oct 2004
    Location
    Cavite,Philippines
    Posts
    31
    why not try

    rs.open"SELECT count(fieldname) as recctr FROM table where field1='0001'",cn

    note that :
    fieldname can be any field in the table


    then,

    if rs("recctr")<1 then
    msgbox"No record found!"
    exit sub
    else
    set rs=new adodb.recordset
    rs.open"SELECT * FROM table where field1='0001'",cn

    end if

    hope this could help!!

  7. #7
    Join Date
    Oct 2004
    Location
    In cousin's house
    Posts
    303
    thanks I will compare whats really the better.

Posting Permissions

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