Results 1 to 2 of 2

Thread: simple VBA problem in MS Access

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904

    simple VBA problem in MS Access

    to simplify:

    I have an Access database with a table TAB1 that has an element EMAIL and I want VBA code that will romp through all of the EMAIL elements of the table so that I can do various tests on the EMAIL string. I have two problems; first I can't find a way to have the VBA code reference the EMAIL elements, and second I can't find a property that will tell me how many rows are in the table. If I could make the FOR EACH work with the table rows as a collection (which I can't figure out how to do either), I wouldn't need the # of rows, but I'd like to know how to get it anyway.

    This all seems as though it should be really simple, but I'm stumped. I'm a newbie using VBA in MS Access 2000

    Thanks for your time.

    Paul Hinds
    [email protected]

  2. #2
    Member
    Join Date
    Sep 2001
    Location
    Taree Australia
    Posts
    33
    if your in access try this (it will work in VB to but you will need to set up references and stuff)

    Code:
    dim db as database
    dim rs as recordset 
    
    set db = currentdb
    set rs = db.openrecordset("Tab1")
    
    dim reccount as integer
    rs.movelast
    reccount = rs.recordcount
    rs.movefirst
    
    do until rs.eof
         if rs("email")  = "something" then 'actual name of field or ,1,2,3 the field number
                     'do something here
         end if
    rs.movenext
    loop
    
    rs.close
    set rs = nothing
    set db = nothing

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