Addnew in a loop

G

Guest

thanks in advance..
I'm doing a manifest for a theatre, so have entries for ticket buyers like: name, row,1st seat to last sea
need to break out each seat by individual buyer: name, row, 1st sea
name, row, 2nd sea
name, row, 3rd seat etc...

did a for...next statement with .AddNew that breaks down for one buyer and adds to table, but can't get it to loop to next ticket buyer. tried looping with EOF, but that goes on an endless loop always adding to the ones I've added.....any ideas

Option Compare Databas
Option Explici
Sub fleshoutseats(
Dim db As DAO.Databas
Dim rs As DAO.Recordse
Set db = CurrentD
Dim buyername As Strin
Dim sectionname As Strin
Dim fromseat As Varian
Dim toseat As Varian
Dim toseatend As Varian
Dim rowname As Varian
Dim seat As Varian

Set rs = db.OpenRecordset("THEATRE", dbOpenDynaset
With r
..MoveFirs
Do Until rs.EO

buyername = rs![BUYER NAME
sectionname = rs!Sectio
fromseat = rs![FROM SEAT NUMBER
toseat = rs![to SEAT NUMBER
toseatend = rs![to SEAT NUMBER] -
rowname = rs!Ro

For seat = fromseat To toseatend Step
..AddNe
rs![BUYER NAME] = buyernam
rs!Section = sectionnam
rs!Row = rownam
rs![FROM SEAT NUMBER] = fromseat +
rs![to SEAT NUMBER] = tosea
rs.Updat

fromseat = fromseat +

Next sea
..MoveNex
Loo

End Wit
End Su
 
G

Guest

With this current code is will only loop the seats, there is no code asking it to loop the buyers. You need to nest a second for loop keyed from the buyers list, I suggest outside the current loop.
 
J

John Spencer (MVP)

Instead of building your outerloop recordset on a table, try building it on a
query that returns all the records in the table. The recordset returned by the
query should stay stable as to the records in it.

Set RS = Db.OpenRecordset("SELECT * FROM Theatre")
 
G

Guest

Hey TGL, I'm trying to make a database for a spanish theatre too, but I'm still thinking on it, maybe you'b be so kind to share your database with me if possible
please write me to (e-mail address removed)
thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top