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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's the syntax for a For Loop and 'Do/While' Loop 1

Status
Not open for further replies.

travismallen

Programmer
Aug 5, 2003
15
US
I'm trying to write a program that creates locations using a counter for example:

Counter = 0
TempLocation = Me.section&"."&Counter

but I want it to check if the location has already been created. I suspect there's a built in function to check for duplicates and returns a true or false.

If there is a function what is it, and if not how can I make a for loop that goes through the table and compares the locations?

Lastly I need to put this a in a While loop or a Do While loop so I can increment the counter, but I don't know the syntax.

Thanks and sorry for the easy questions, man I wish Access used java instead...

___________________________
"I am what I am" - Popeye
Travis M. Allen
 
if you want to do this a certian number of times then a for loop is best.

dim a as integer
For a = 1 to 20 (or) For A = 0 to 19
TempLocation = Me.section & "." & trim(a) 'note the "TRIM" is to get rid of the sign holder in front of the number
Next

also a do loop will look like this
Dim Counter as Integer 'Note Integer is only good upto a number 32700 something
Counter = 0
Do while somevalue = true
Counter = Counter +1
TempLocation = Me.section & "." & trim(Counter)
Loop


DougP, MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top