code willl not stop running (1 Viewer)

ajetrumpet

Banned
Local time
Yesterday, 20:57
Joined
Jun 22, 2007
Messages
5,638
Hello all,

i have a form in which some code was run once in the background in a loop. My mistake was i missed a line of code, and now everytime the form is opened, the code keeps looping. I have tried:

*restarting
*pushing stop, pause, go, etc... In vb window
*stopping the code permanently by switching to design view

i have not tried importing the form into a new database...suggestions please?
 

SOS

Registered Lunatic
Local time
Yesterday, 18:57
Joined
Aug 27, 2008
Messages
3,517
Open the database by holding the SHIFT key down and then go into the form in Design view and go to the code and fix it there.
 

Banana

split with a cherry atop.
Local time
Yesterday, 18:57
Joined
Sep 1, 2005
Messages
6,318
Also to break a infinite loop or such, CTRL+BREAK
 

rainman89

I cant find the any key..
Local time
Yesterday, 21:57
Joined
Feb 12, 2007
Messages
3,015
This is a pretty extreme solution, but i guarantee it will work.

Step 1- Throw computer out of window.

Vualah(sp)!!! Loop stops
 

rommelgenlight

Registered User.
Local time
Yesterday, 18:57
Joined
Mar 23, 2009
Messages
36
is this for real? ajetrumpet is being troubled by this problem? or it is just a challenge for us who can answer the problem?
 

rommelgenlight

Registered User.
Local time
Yesterday, 18:57
Joined
Mar 23, 2009
Messages
36
no. its ok! I just can't believe it. i bet you have many friends here is forum that is available for you!
 

rainman89

I cant find the any key..
Local time
Yesterday, 21:57
Joined
Feb 12, 2007
Messages
3,015
i had a bad day, ok? i'm sorry i asked. nice solution rainman!

Its Friday. You will enjoy doing that!! :D

Don't forget to rep me for my most helpful post! HAHA! :p
 

honda882000

Registered User.
Local time
Yesterday, 21:57
Joined
Apr 16, 2009
Messages
62
Is this form your main switchboard (opens with database open)? If not, you can just go to vba view (Alt-F11) and look at the code for the form from there.
 

ajetrumpet

Banned
Local time
Yesterday, 20:57
Joined
Jun 22, 2007
Messages
5,638
Also to break a infinite loop or such, CTRL+BREAK
Banana,

everytime I open the VB window when the form is NOT in design view, the code is still running! how do I fix this!? :rolleyes: if you please...?
 

KeithG

AWF VIP
Local time
Yesterday, 18:57
Joined
Mar 23, 2006
Messages
2,592
Why can't you open up the VBE when the form is is design view?
 

Banana

split with a cherry atop.
Local time
Yesterday, 18:57
Joined
Sep 1, 2005
Messages
6,318
I'm pretty sure you can break code without having to open VBE at all.

In fact, I just tried it out- created a form, added an infinite loop in the open event, opened it. Ctrl+Break broke the execution and took me to the VBE.
 

ajetrumpet

Banned
Local time
Yesterday, 20:57
Joined
Jun 22, 2007
Messages
5,638
i am testing this stuff again.

i know it breaks Banana, but everytime i went back and opened the damn form again, it would continue!
 

ajetrumpet

Banned
Local time
Yesterday, 20:57
Joined
Jun 22, 2007
Messages
5,638
now i've gotten everything to work, but the browser pages aren't populating like they should from the listbox. go figure! i'm about ready to take Rainman's approach. =)
 

ajetrumpet

Banned
Local time
Yesterday, 20:57
Joined
Jun 22, 2007
Messages
5,638
here are two pieces of code that I have:
Code:
Option Explicit

Dim ie As Object, txtusername, txtpassword, txtextra1, btnsubmit, frmnumber

Dim counter As Integer, listCounter As Long, ctrl As Control

Private Sub cmdlogin_Click()

On Error Resume Next

Set ctrl = Me.listURLs

For listCounter = 1 To 2

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

  If ctrl.Selected(listCounter) Then

  If IsNull(ctrl.Column(10, listCounter)) Then
    GoTo NextCounterLoop
  End If

counter = 0
txtusername = ctrl.Column(4, listCounter)
txtpassword = ctrl.Column(6, listCounter)
txtextra1 = ctrl.Column(8, listCounter)
btnsubmit = ctrl.Column(7, listCounter)
frmnumber = ctrl.Column(10, listCounter)

StartProcess:

Debug.Print frmnumber
Debug.Print ctrl.ListCount - 1


Set ie = CreateObject("internetexplorer.application")

  ie.Visible = True
    apiShowWindow ie.hwnd, SW_MAXIMIZE
      ie.navigate ctrl.Column(3, listCounter)

    While ie.busy
      DoEvents
    Wend

FillLogin:

  'If counter < 3 Then

        ie.document.Forms(frmnumber).Item(txtusername).Value = ctrl.Column(1, listCounter)
        ie.document.Forms(frmnumber).Item(txtpassword).Value = ctrl.Column(2, listCounter)
        
            If Not IsNull(ctrl.Column(5, listCounter)) Then
              ie.document.Forms(frmnumber).Item(txtextra1).Value = ctrl.Column(5, listCounter)
            End If

'counter = counter + 1

'GoTo FillLogin

  'Else
  
    If ctrl.Column(9, listCounter) = -1 Then
      GoTo SUBMITFORM
    Else

SUBMITBUTTON:
  ie.document.Forms(frmnumber).Item(btnsubmit).Click
    GoTo CONTINUE

    End If

SUBMITFORM:
  ie.document.Forms(frmnumber).submit

CONTINUE:
  While ie.busy
    DoEvents
  Wend

  'End If

Set ie = Nothing

  End If

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

NextCounterLoop:
   Next listCounter

End Sub
Code:
Option Explicit

Dim ie As Object, txtusername, txtpassword, txtextra1, btnsubmit, frmnumber, counter As Integer

Private Sub cmdURLgo_Click()

  If IsNull(Me.FORM_NUMBER) Then
    Exit Sub
  End If

On Error GoTo ErrorHandler

counter = 0
txtusername = Me.UN_ELEMENT
txtpassword = Me.PW_ELEMENT
txtextra1 = Me.ADD_ELEMENT
btnsubmit = Me.BTN_ELEMENT
frmnumber = Me.FORM_NUMBER

StartProcess:

Set ie = CreateObject("internetexplorer.application")

  ie.Visible = True
    apiShowWindow ie.hwnd, SW_MAXIMIZE
      ie.navigate Me.WEBSITE

    While ie.readystate < 4
      DoEvents
    Wend

FillLogin:

  If counter < 3 Then

        ie.document.Forms(frmnumber).Item(txtusername).Value = Me.USERNAME
        ie.document.Forms(frmnumber).Item(txtpassword).Value = Me.PASSWORD
        
            If Not IsNull(Me.IDENTIFICATION) Then
              ie.document.Forms(frmnumber).Item(txtextra1).Value = Me.IDENTIFICATION
            End If

counter = counter + 1

GoTo FillLogin

  Else
  
    If Me.FRM_SUBMIT = -1 Then
      GoTo SUBMITFORM
    Else

SUBMITBUTTON:
  ie.document.Forms(frmnumber).Item(btnsubmit).Click
    GoTo CONTINUE

    End If

SUBMITFORM:
  ie.document.Forms(frmnumber).submit

CONTINUE:
  While ie.busy
    DoEvents
  Wend

Set ie = Nothing
  Exit Sub

  End If

ErrorHandler:
  ie.Quit
    GoTo StartProcess

End Sub
both are similar in nature. the only difference is that the top one does not fill the login information when I navigate to the website. any ideas anyone please?
 

Users who are viewing this thread

Top Bottom