Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / March 2007

Tip: Looking for answers? Try searching our database.

how to stop a loop and run code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
zionsaal@gmail.com - 08 Mar 2007 18:36 GMT
I have a table with one field in it and I wont to draw one record so
I created a form and I created a loop to go to the next record
randomly the whole table and then every second minute I  stop the loop
and I
got the winner, means the record where the loop stop in it

but I don't have a way to stop the loop only by pressing ctrl break
I wont to code that when i will press any key it should stop running
the code and it should came up a MSG box with the name
any help please?
thanks

here is the code
Private Sub Command2_Click()
gggg:
DoCmd.GoToRecord , , acFirst
Do Until Me.NewRecord
DoCmd.GoToRecord
{here I wont to put: if key = enter then exit sub and do this and
this}
Loop
GoTo gggg
End Sub
Ralph - 08 Mar 2007 19:15 GMT
Try DoEvents

Option Compare Database
Option Explicit
Dim bolrun As Boolean

Private Sub Command2_Click()
DoCmd.GoToRecord , , acFirst
bolrun = False
Do Until bolrun = True
DoCmd.GoToRecord
 DoEvents
Loop
End Sub

Private Sub Command2_KeyDown(KeyCode As Integer, Shift As Integer)
bolrun = True
End Sub

> I have a table with one field in it and I wont to draw one record so
> I created a form and I created a loop to go to the next record
[quoted text clipped - 19 lines]
> GoTo gggg
> End Sub
zionsaal@gmail.com - 08 Mar 2007 21:54 GMT
> Try DoEvents
>
[quoted text clipped - 41 lines]
>
> - Show quoted text -

thanks
here is the code

Option Compare Database
Dim bol As Boolean

Private Sub Command2_Click()
bol = False
gggg:
DoCmd.GoToRecord , , acFirst
Do Until Me.NewRecord
DoCmd.GoToRecord
DoEvents
Loop
If bol = True Then Exit Sub
GoTo gggg
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
bol = True
MsgBox Me.MasterID
End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.