Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Access 2007 VBA Programmer's Reference ISBN: 978-0-470-04703-3
This is the forum to discuss the Wrox book Access 2007 VBA Programmer's Reference by Teresa Hennig, Rob Cooper, Geoffrey L. Griffith, Armen Stein; ISBN: 9780470047033
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Access 2007 VBA Programmer's Reference ISBN: 978-0-470-04703-3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 24th, 2014, 11:05 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Code Found in Append-Only Field section of the book

In Chapt 6 page 114.

I've created the "lstHistory" form, but I don't know how to call the following code or where/how to apply it on the form.

I'd like the exact syntax if possible? Any assistance is greatly appreciated. Thanks in advance

Code:
Private Sub ShowColumnHistory(strTableName As String, strFieldName As String)
    'History data is in this format:
    '[Version: Date Time ] History Data
    Const VERSION_PREFIX As String = "[Version: "

    Dim strHistory As String
    Dim strHistoryItem As String
    Dim astrHistory() As String
    Dim lngCounter As Long
    Dim datDate As Date
    Dim datTime As Date
    Dim strData As String

    'Get the column history
    strHistory = Application.ColumnHistory(strTableName, strFieldName, "")

    'Make sure there is history data
    If Len(strHistory) > 0 Then
	'Parse the column history into separate items.
	'Each item in the history is separated by a vbCrLf, but
	'if there are carriage-returns in the memo field data
	'you will get unexpected results. Split on the VERSION string
	'in the history data.
	astrHistory = Split(strHistory, VERSION_PREFIX)

	'Adding these lines ensures this code works regardless of
	'how the control is configured on the form
	Me.lstHistory.RowSourceType = "Value List"
	Me.lstHistory.ColumnCount = 3
	Me.lstHistory.ColumnHeads = True

	'Add column headings to the list box
	Me.lstHistory.AddItem "Date;Time;History"

	'Enumerate the history data in reverse
	'to fill the list box in descending order
	For lngCounter = UBound(astrHistory) To LBound(astrHistory) Step -1
	    'Parse the history data
	    strHistoryItem = astrHistory(lngCounter)

	    If Len(strHistoryItem) > 0 Then

		'Parse the date from the history data.
		'This example parse the default US date format.
		datDate = CDate(Left(strHistoryItem, InStr(strHistoryItem, " ") - 1))
		strHistoryItem = Mid(strHistoryItem, InStr(strHistoryItem, " ") + 1)

		'Parse the time from the history data
		datTime = CDate(Left(strHistoryItem, InStr(strHistoryItem, " ] ") - 1))
		strHistoryItem = Mid(strHistoryItem, InStr(strHistoryItem, " ] ") + 3)

		'Add the history item to the list box.
		Me.lstHistory.AddItem datDate & ";" & datTime & ";" & strHistoryItem
	    End If
	Next
    Else
	MsgBox "There is no history information for the specified field"
    End If
End Sub

Last edited by achindah; July 24th, 2014 at 11:11 AM.
Reply With Quote
Reply


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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Found an error in the book padhma BOOK: Microsoft SQL Server Reporting Services Recipes: for Designing Expert Reports 0 November 8th, 2011 06:34 PM
Field not found when binding dataset to gridview sg48 ASP.NET 3.5 Basics 6 April 10th, 2010 04:15 PM
Field not found when binding dataset to gridview sg48 ASP.NET 3.5 Basics 2 April 9th, 2010 06:52 PM
Append records with 1 incrementing field Mitch SQL Language 3 May 26th, 2005 08:40 AM



All times are GMT -4. The time now is 08:30 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.