Results 1 to 6 of 6
  1. #1
    EricMK is offline Novice
    Windows 2K Access 2003
    Join Date
    Jun 2009
    Posts
    8

    Enumerating records in a table

    This is probably a very trivial question, so I'm sure any of you could answer this one.



    I'm an experienced C++ programmer with several years of experience. I have a very small amount of experience in writing Excel macros using VBA. I have no experience whatsoever with Access. All the info I can find on Access is either too basic (for total beginners) or too technical and confusing (i.e. MS reference material).

    What I want to do is print a set of flash cards from an Access database. To do that I want to enumerate all the records in a particular table, extract some data from the records, print some of it on one side of the flash cards and the rest on the other side. It's very trivial; any one of you could do it in about five minutes.

    But looking through the MS reference material, I can't figure out how to enumerate the records. I found an example of how to enumerate the tables in the database, but how do I enumerate the records in the table?

    I've done something similar with Excel, where I enumerated the rows in a worksheet. If I remember correctly, I first enumerated the worksheets in the spreadsheet, then used the row collection property to enumerate the rows in the worksheet. I would assume that I would do something similar in Access, but I haven't been able to find a similar record collection property to enumerate the records. So what do I have to do to enumerate the records?

    One further question: When I create the macro, do I have to create a form with a button to click to print the flash cards, or can I have the macro print the flash cards directly. All the VBA macros that I created for Excel would bring up a form or dialog box to do anything, so I'm not sure whether I can write a marco that will print the flash cards directly. Thank you.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Have you tried creating a report that would do what you want?

  3. #3
    EricMK is offline Novice
    Windows 2K Access 2003
    Join Date
    Jun 2009
    Posts
    8
    My wife tried creating a report, but it wasn't what we wanted. My wife created the database and has more experience with Access than I do, but she doesn't know any programming, so I offered to write a macro to do what we wanted to do.

    There were two problems with the report that she created. First, the data was not in the format that we wanted. Each record was printed on a single line, rather than as flash cards, front and back. Perhaps the formatting could be tweeked to make them come out as flash cards. But a more serious problem was that there are some fields that we do not want printed on the flash cards, but on the report all the fields were printed.

    If you think that we accomplish what we want using reports, then perhaps I'll post another topic in the Reports forum to ask about this. However, after we finish the flash cards, there are some other things that I want to do with the database that will require enumerating through the records, so I'd still like to know how to enumerate through the records, even if the flash cards can be accomplished entirely through reports.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    A report only prints the fields that you have on your report. If you don't want a field to show then delete the control on the report that displays the field. As for enumerating a RecorsSet, I'm not sure what you want. You can use either a DAO or ADO RecordSet to "walk" through a table one record at a time if that is what you are talking about.

  5. #5
    EricMK is offline Novice
    Windows 2K Access 2003
    Join Date
    Jun 2009
    Posts
    8
    I tried doing this with reports, but there was one problem that I encountered. The flash cards are for training employees at a chain of vitamin stores. I want the front of each flash card to contain the name of a disease, and the back to contain the names and dosages of vitamins and herbs to recommend for the disease. So I created two reports, one for the front and one for the back. The problem was that some diseases only have two or three products to recommend, while others may have eight or ten, so that the front and back do not line up.

    So what I'd like to know is whether reports or macros are the best way to accomplish this. If I use reports, then I need to pad the back side with blank lines so that the back and the front of the flash cards line up. Is it possible to do this with reports? If I use macros, then I need to enumerate the records and print each record in the right format. Is there a print command available to use in a VBA macro? I couldn't find one in the documentation.

    If neither reports nor macros will do what I want to do, then I will have to write a stand-alone program to print the flash cards. I want to write a stand-alone program later for employee training, to quiz the employess on their knowledge, so I could always add a flash-card feature to the program, but I was hoping that I could get the flash cards done quickly and do the training program later.

    I checked out the DAO and ADO recordsets, and I do remember using them many years ago in a C++ program that I wrote to read Access databases. I remember that reading Access and Excel files was very tricky using C++. so I'll be using VBASIC to write the employee training program.

    I only have a limited amount of time to work on this, so if you could point me in the right general direction as to whether I can pad the records in a report to make them all the same size, whether I can use marcos to print out records, or whether I need to write a stand-alone application, then that would be much appreciated. Thank you.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Without seeing your flash cards I woud guess that is should be possible to get things to line up. As for the rest of your questions, I believe Access could handle all of it but the application you use will have to be your choice. Only you know your skill set and the time available.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Inserting multiple records into a table
    By New2Access in forum Programming
    Replies: 1
    Last Post: 07-07-2011, 09:18 PM
  2. Query two different records in the same table
    By Eildydar in forum Access
    Replies: 5
    Last Post: 04-15-2009, 01:39 PM
  3. Delete all records in a table?
    By bob646 in forum Access
    Replies: 1
    Last Post: 05-20-2007, 11:41 PM
  4. Creating a string from all records in a table
    By ocordero in forum Programming
    Replies: 2
    Last Post: 08-07-2006, 09:21 AM
  5. Replies: 1
    Last Post: 03-17-2006, 12:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums