Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 07-01-2009, 03:20 PM
EricMK EricMK is offline Windows 2K Access 2003 (version 11.0)
Novice
 
Join Date: Jun 2009
Posts: 8
EricMK is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 07-02-2009, 11:49 AM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

Have you tried creating a report that would do what you want?
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
  #3  
Old 07-02-2009, 06:10 PM
EricMK EricMK is offline Windows 2K Access 2003 (version 11.0)
Novice
 
Join Date: Jun 2009
Posts: 8
EricMK is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 07-02-2009, 07:16 PM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

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.
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
  #5  
Old 07-07-2009, 07:21 PM
EricMK EricMK is offline Windows 2K Access 2003 (version 11.0)
Novice
 
Join Date: Jun 2009
Posts: 8
EricMK is on a distinguished road
Default

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.
Reply With Quote
  #6  
Old 07-08-2009, 05:40 AM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

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.
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query two different records in the same table Eildydar Access 5 04-15-2009 11:39 AM
Delete all records in a table? bob646 Access 1 05-20-2007 09:41 PM
Inserting multiple records into a table New2Access Programming 0 02-18-2007 09:46 PM
Creating a string from all records in a table ocordero Programming 2 08-07-2006 07:21 AM
Selecting and modifying records in a table Ed H Access 1 03-17-2006 09:04 AM


All times are GMT -8. The time now is 02:40 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.