A New Data Programming Style

While working on VB projects with associated Jet databases, I found that I was creating a lot of individual handling functions for reading, writing, and validating data. It was hard to keep track of changes made to the table structures and to their associated handling functions.As a result, I’ve developed new programming style. My read /write and special functions are all in one routine selected by case logic based on descriptive strings. The strings are used only within the programs and are self documenting to some extent. Data is passed through a Public WorkVariant array:

 Public MyDB As DatabasePublic WorkVariant(10) As VariantDim Dummy As IntegerSet MyDB = OpenDatabase("testjet3db")'Sample callsDummy = NameTableIO("writerecord")Dummy = NameTableIO("readrecord")Public Function NameTableIO_	(ByVal whichAction As String) As Integer'Assumes navigation to the record has 'been made externallyDim MyTable As RecordsetDim ErrorStage As StringOn Error GoTo NameTableIOError	NameTableIO = True	ErrorStage = "OpenRecordSet"	Set MyTable = MyDB.OpenRecordset("NameTable")	ErrorStage = "AfterOpen"	Select Case whichAction		Case "readrecord"			WorkVariant(1) = MyTable![FirstName]			WorkVariant(2) = MyTable![Age]		Case "writerecord"			MyTable.Edit				MyTable![FirstName] = WorkVariant(1)				MyTable![Age] = WorkVariant(2)			MyTable.UpdateCase "validateage"	'specialized routine		'etcEnd SelectNameTableIOErrorExit:	If ErrorStage <> "OpenRecordSet" Then		MyTable.Close	End If	Set MyTable = NothingExit FunctionNameTableIOError:	NameTableIO = False	MsgBox Error$ &_		" Error trap in NameTableIO " & _		"at " & ErrorStage & " Action: " & whichAction	Resume NameTableIOErrorExitEnd Function
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS