Results 1 to 3 of 3

Thread: How do You Find if there is a record or not

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Posts
    28

    Post

    Hi how do You Find if there is a record with the ID field that = 1

    Pleas Help Thanks

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    It depends on what you are using to connect to the database.

    I'll give you an example of what I use to play with databases.

    dim dbsData as database, rcdTable as recordset, lngIDnum as long

    lngIDnum = "123456"
    set dbsData = OpenDatabase("mydata.mdb")
    'this is the name of what ever database you connect to

    set rcdTable = dbsData.OpenRecordset("Select * from table where IDfield = " & lngIDnum)
    'using a variable to show how it would work
    'if you don't want to - ("Select * from table where IDfield = 123456")
    if rcdTable.eof then
    'this record ID was not found
    else
    'record found
    msgbox "Found record.", vbokonly, "Found"
    end if
    rcdTable.close
    dbsData.close

    This would check for a record with id of 123456 in field IDfield, in table Table from database mydata.mdb


    Hope this helps.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Posts
    28

    Post

    Thanks a ton

Posting Permissions

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



Click Here to Expand Forum to Full Width