Results 1 to 8 of 8

Thread: Do...Loop Question

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    7

    Post

    I want to programatically loop through all the rows in my database when a user clicks on a pushbutton.

    However I get an error:
    "Object variable or with block variable not set"

    Here's what I am doing:

    do while not adoTargets.recordset.eof
    ...
    ... processing code here
    ...
    loop

    What am I doing wrong ? I want it to loop until EOF.

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089

    Post

    Have you definately gone adoTargets.recordset.movefirst before the loop and make sure your recordset object is attatched to a database recordset, I still use DAO myself so i'm not sure.

    Hope this helps

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    7

    Post

    Here's what my code looks like now:

    --------------------------------------------
    adoTargets.recordset.movefirst

    do while not adoTargets.recordset.EOF
    ...
    ... Processing code here
    ...
    loop

    --------------------------------------------
    I am now getting an error on the first stmt:
    adoTargets.recordset.movefirst

    I get the same error:

    "Object variable or with block not set"

    Hummmm.... suggestions ? anyone please??

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

    Post

    Did you set the recordset anywhere? You have to set adoTargets to something. I'm not sure how it works with ADO exactly (whether you're using a physical control) but

    set adoTarget = dbDatabase.OpenRecordset(Table)

    might work with Table being the name of your table and dbDatabase being your database. If it's a physical control - you need to do this:

    adoTarget.Recordsource = "Select * from table"

    or something like that.

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    7

    Post

    Within the ADO data control I set the recordsource to:
    SELECT * from Targets

    (I have double checked to be sure that the table name is spelled correctly.)


  6. #6
    New Member
    Join Date
    Apr 2004
    Location
    Pune
    Posts
    2

    Re: Do...Loop Question

    Chk 4 ur connection, ur recordset is not opening at all
    Thanx & Regards,
    Suresh Mishra

  7. #7
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Do...Loop Question

    Did you know the date of that thread?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  8. #8
    New Member
    Join Date
    Apr 2004
    Location
    Pune
    Posts
    2

    Post Re: Do...Loop Question

    Yes I did but then I also didn't C the satisfactory reply 2 last post n I thought that my post might help in future if required. If the prob is already solved I think this post should not hav come. I'd advice stop pointing out this kind of logical things like kids.
    Thanx
    Thanx & Regards,
    Suresh Mishra

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