Hello! My first question 😊 I have a query (LuckyNumberQ) that lists individual names and a lucky number. For example: Jim Kirk 23 Leonard McCoy 17 Jean-Luc Picard 11 I'd like to be able to generate a query/report showing each individual with a number of ticket entries based on their lucky number. For example: Name Ticket Jim Kirk 10001 Jim Kirk 10002 Jim Kirk 10003 .... to Jim Kirk 10023 (23 entries) Leonard McCoy 10024 Leonard McCoy 10025... to Leonard McCoy 10040 (17 entries) Jean-Luc Picard 10041 Jean-Luc Picard 10042... to Jean-Luc Picard 10051 (11 entries)
It's fairly easy to export the LuckyNumberQ into Excel and add field etc. but it would be better if Access would do all the necessary. Is it possible? Apologies if this question is in the wrong area.
David BurnsOP
@Reply 3 years ago
I'm thinking along the lines of some code that does something like the following:
Let t = 10001 (the first ticket number)
For the first member in LuckyNumberQ (however this is determined)
Let n = LuckyNumberQ.LuckyNumber
Let c = 1 (a counter)
While c <> n Do
INSERT INTO NewTableT LuckyNumberQ.FirstName, LuckyNumberQ.LastName, t
Let c = c + 1
Let t = t + 1
Next Member
Exit routine if no more members
Then have a report based on NewTableT
Presuming the correct code, would the above be a viable solution?
Will future lessons I'm subscribed to cover how I might approach doing this?
Thanks
David BurnsOP
@Reply 3 years ago
I guess this thread would have been better in the Access Forum rather than here in Expert 8.
Anyway, I've now pulled together VBA that does what I want so I have a new table being created with member names and ticket numbers. I'm now tackling a report that will print each member's ticket numbers on separate pages.
David BurnsOP
@Reply 3 years ago
Well, though it is doing what I want, the VBA occasionally has a hiccup/hiccough where an unexpected section of records that would normally appear partway down the new table actually appear at the start of the new table. (I expected that calling the recordset would see the first entry of the interrogated query appear in the first row of the new table but it doesn't always.)
I've also got the report done as well. I eventually used the labels option so three records appear across the page and each member's tickets appear on separate pages. Yay!
I think I'll reward myself with a coffee and digestive lol
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Access Expert 8.