Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use a knob to jump out of a loop 1

Status
Not open for further replies.

Schaap

Technical User
Jul 6, 2004
54
NL
About VBA I'm just a starter !
I wanna know if it's possible to jump out of a loop when I click on knob on the screen. See the code below, the While do loop and the knob "Knop82_Click".

According to VBA I only may use a function or a variable in the While loop.
Please let me know what to do !

Loop-Code:

Set rs = Db.OpenRecordset("select * From Investment;")
With rs
Do
Me.NewInvestmentNummer = InvestNR
Me.NewInvestmentDatum = Datum
Me.NewApplicantNaam = username
InvestName = Me.NewInvestmentNaam
BudgetY = Me.NewBudgetJaar
InvestPurpose = Me.NewInvestmentDoel
Necess = Me.NewNecessity
InvestDescrip = Me.NewInvestmentDescription
TestDescrip = Me.NewTestDescription
Howtest = Me.NewHowTestingNow
InvestReal = Me.NewInvestmentRealisation
While Knop82_Click() = "-1"

Knob-Code:

Private Sub Knop82_Click()

Set rs = Db.OpenRecordset("select * From Investmentplanning;")
With rs
.AddNew
!IndexNumber = IndexNR
!InvestDate = Datum
!InvestNumber = InvestNR
!ApplicantName = username
!InvestmentName = InvestName
!BudgetYear = BudgetY
!InvestmentPurpose = InvestPupose
!Necessity = Necess
!InvestmentDescription = InvestDescrip
!TestDescription = TestDescrip
!HowTestingNow = Howtest
!InvestmentRealisation = InvestReal
MsgBox ("Weet u zeker dat de ingevulde gegevens kloppen !")
.Update
MsgBox ("Uw Application Form is opgenomen in de database")
'DoCmd.OpenForm "Newapplicationform", acNormal
rs.Close
End Sub
 
Here's one way to do it. Set the Tag property of the Knob button to "Go". When the user clicks on it, set the Tag property to "Stop". In your loop check for "Stop" or "Go".
 
Sorry but I don't understand it properly.
I have to set the Tag property of the knob button to "Go".
I suppose this means that I type "Go" behind the line "When clicking" at the Tag property of the knob. Instead of "Go" I use a procedure for this, namely to go to the private sub knop82_Click (see code in previous thread).
And how can I change "Go" into "Stop" when an user clicks on the knob. I suppose it's with another property of the knob.
Please be a little more specific in this, so I can understand it too.

Thanks so far
 
Maybe I don't understand what you're trying to do. But this is what I think you want.

Loop Code:

Do
...
...
While Knop82.Tag = "Go"


Knob Code:

Private Sub Knop82_Click()

Knop82.Tag = "Stop"

rest of your code here

End Sub

You will need to set Knop82.Tag initially to "Go
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top