Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8224449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:04:32+00:00 2026-06-07T15:04:32+00:00

I am getting a continuous loop (I believe). When I run the code, I

  • 0

I am getting a continuous loop (I believe). When I run the code, I get the MsgBox prompt, click ok, and the program just runs and runs and never ends? At first I assumed it was a connection to the file error, but if that was the case, I should be receiving an error when ADO tries to connect to the file, correct?
The file isn’t that big, only 70ish rows. The way I have the MsgBox set, it should prompt for an OK to be clicked every iteration through the loop, but I never receive another MsgBox. Suggestions?

' The following section reads from the elec_copy field's hyperlink
' It scans the Excel file for items it needs to include into the table
' It enters those cells into the TABLE 'items_needed_table'
'
' Selects row by row, and if the item has been marked TRUE, inserts
' That row into the TABLE 'items_needed_table'

' Open a connection to Excel
On Error Resume Next

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001

Set objConnection = CreateObject("ADODB.Connection")

objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & elec_copy.Value & ";" & _
        "Extended Properties=""Excel 12.0 Macro;HDR=Yes;"";"

' Decalre a RecordSet Object
Set objRecordSet = CreateObject("ADODB.Recordset")

' Grab all Rows in the Plain_VDR Sheet where 'needed' column == TRUE
objRecordset.Open "SELECT line_no,desc,weeks FROM [Plain_VDR$] WHERE needed = TRUE", _
    objConnection, adOpenStatic, adLockOptimistic, adCmdText

' Write the information pulled, into the TABLE 'items_needed_table' in Access Database
Do Until objRecordset.EOF
    MsgBox("" & qd.Parameters("p2"))
    Set qd = data_base.CreateQueryDef("")
    qd.sql = "INSERT INTO items_needed_table(pr_no, line_no, desc, weeks) " & _
        "Values([p1],[p2],[p3],[p4])"
    qd.Parameters("p1").Value = pr_num.Value
    qd.Parameters("p2").Value = objRecorset.Fields.Item("line_no")
    qd.Parameters("p3").Value = objRecordset.Fields.Item("desc")
    qd.Parameters("p4").Value = objRecordset.Fields.Item("weeks")
    qd.Execute
    objRecordset.MoveNext
Loop

' Close Database connection
data_base.Close

Thanks in advance for any help!
Nathan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:04:34+00:00Added an answer on June 7, 2026 at 3:04 pm

    Get rid of the line On Error Resume Next. It should almost never be used. Because of that line, you have no idea where the error that is causing the loop is occurring.

    Another good idea is to always use Option Explicit at the top of each module. This will ensure that you always declare your variables and saves more grief than anyone would think possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting my code caught in an infinite while loop. It is nothing
I am getting the continuous error of IndexOutOfRangeException in my c# code. The code
I'm just getting started with CruiseControl .NET (using the Manning Continuous integration book that
I am continuously getting Error Code The ORA-01033: ORACLE initialization or shutdown in progress
I am writing a process that will run continuously, getting messages on a queue
i have a program(winform) that runs through a lot of files(in the area of
I asked some time ago for help getting continuous integration working in Delphi previously.
My saga with x86 assembly continues, I'm getting into an infinite loop with this
I need to play mp3 audio data in iPhone continuously. I am getting continuous
I am getting a continuous stream of characters from a ASCIIReader and I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.