416-621-9348 cgreaves@chrisgreaves.com Visit www.ChrisGreaves.com for this image! Chris_GEDC1894_Head (Small).JPG
Home Services Products

Snapshot of all Data

From time to time you will want to make a snapshot of an entire record for printout.

Perhaps you are going to visit a prospect and would like to take with you a compressed printout holding the address and telephone number, contact names and a history of previous conversations. In short, everything you know about the prospect.

This will be a modified version of the previous exercise - we will want to dump all the controls to a text file that we can print out.

We will need a Command Button called cmd_SnapShot with a caption "Snapshot".

I would be inclined to code this by hand, rather than by using the Wizard.

Your skeletal code will look like this:

Private Sub cmd_Snapshot_Click()
End Sub

We would like to build a string with one line per field.

This string will be very much like the string we exported for deleted data, but instead of using a TAB character (suitable for import into a spreadsheet), we will use a carriage-return line-feed (suitable for import into Word.

Private Sub cmd_Snapshot_Click()
Dim strRecord As String
strRecord = strFormRecord(Me, vbCrLf)
Call strPrintFile("Snapshot.DOC", strRecord)
End Sub

It's so easy when you know how!

In the example above I have used a file extent of ".DOC".

Our utility procedure " strPrintFile" will recognize the extent and will not append a ".TXT" extent.

In consequence, although my snapshot file will be truly a text file, and a very small one at that (about 300 characters), I will be able to double-click on the name and launch my word processor, making the data immediately available for printing.

Note too the slight difference in the call to "strPrintFile", where I have used the vbCrLf character as a delimiter instead of the vbTab.


Loading

Toronto and Mississauga, Sunday, December 05, 2010 3:19 PM

Copyright © 1996-2010 Chris Greaves. All Rights Reserved.