BCE24 | Virtual Brand Ambassadors: Making Brands Personal - John Meulemans
List to Data (MS Access)
1. List To Data
by TØny Hine find me on G+
My website with loads more MS Access
videos here:-
Add a Check List to your DB
(Video 1 (8:02min) Is a run through of “THIS” Google Presentation
Published on 11 Apr 2014
2. List To Data
Done With just 3 Tables and 2 Functions
1. Master table "tblMaster"
2. Data table "tblData"
3. List table "tblList"
1. fCopyListToData
2. fAppendListToData
3. (Some Helper Functions)
3. Wedding Planners Example
In this case the Master Table "tblMaster" will contain details about the
"wedding planners" customers.
The Data Table "tblData" will store data for each individual customer.
Finally the List Table "tblList" lists the "check off" items that need to be
transferred to the data table "tblData".
4. The transfer of the list into the data table is
performed by two functions.
Copy List" fCopyListToData
Function fCopyListToData(lngMasterID As Long)
Dim curDB As DAO.Database
Dim rsList As DAO.Recordset
Set curDB = CurrentDb
Dim lngSet As Long
Dim lngID As Long
Set rsList = curDB.OpenRecordset(fSQL_List, dbOpenForwardOnly)
Do Until rsList.EOF
lngSet = rsList!listSets
lngID = rsList!listID
Call fAppendListToData(lngMasterID, lngSet, lngID)
rsList.MoveNext
Loop
End Function 'fCopyListToData
"Append List" fAppendListToData
Function fAppendListToData(ByVal lngMasterID As Long, ByVal lngSet As Long, ByVal lngID
As Long)
Dim strSQL0 As String
Dim strInsert As String
Dim strValues As String
strInsert = "INSERT INTO tblData (dataLinkID, dataSets, dataItems) "
strValues = "VALUES (" & lngMasterID & ", " & lngSet & "," & lngID & ");"
strSQL0 = strInsert & strValues
CurrentDb.Execute strSQL0
End Function 'fAppendListToData
5. In this article I would like to demonstrate one method of achieving this. I will try and keep the terms I use to describe this process as general as possible, so that it is
easy to relate to the structure in different circumstances.
In searching the Internet for checklists, it took me a while to find one that fitted my needs, unfortunately it was a "wedding list". I apologise if my choice terrifies any
gentlemen reading this.
The minimum number of tables required to make this work is 3 tables, I have given these generic terms: master, data and list. To explain the use of these tables I will
refer to a specific case. Consider a business which manages weddings for couples.
In this case the master table "tblMaster" will contain details about the wedding planners - “Customers”.
The data table "tblData" will store the data for each individual customer.
Finally a table "tblList" that lists the "check off" items that need to be transferred to the data table "tblData".
The transfer of the list into the data table is performed by just two functions "Copy List" fCopyListToData, and "Append List" fAppendListToData. There are several
other supporting functions in this example.
fCopyListToData puts the data from the list (tblList) into a recordset and then loops through the record set extracting the Row information from each field, then
transfers that information via the function fAppendListToData into the data table "tblData".
"tblData" is what this code is about, it is this set of data that is created. Looking at the data table (tblData) we have five fields: dataID, dataLinkID, dataSets,
dataItems and dataTickedOff.
dataID is not necessary and can be ignored.
dataLinkID is used to relate the values in this table (tblData) to the master table (tblMaster).
"dataSets" would not be necessary if you only had one set of data in your list. It is quite common to have a list divided into separate sets of information so in that
instance it would be required and really for a single list with only one set, then you just add a "1" (or some other identifier) and treat it as if it was a set from a
number of sets.
"dataItems" links back to the table list "tblList" and can be used to find the string value related to each item.
"dataTickedOff" is a boolean field which allows you to to flag whether a list item has been done, or not done.
6. fCopyListToData puts the data from the list (tblList) into a recordset and then loops through the record set extracting the Row
information from each field, then transfers that information via the function fAppendListToData into the data table "tblData".
7. fCopyListToData puts the data from the list (tblList) into a recordset and then loops through the record set extracting the Row
information from each field, then transfers that information via the function fAppendListToData into the data table "tblData".
8. fCopyListToData puts the data from the list (tblList) into a recordset and then loops through the record set extracting the Row
information from each field, then transfers that information via the function fAppendListToData into the data table "tblData".
9. fCopyListToData puts the data from the list (tblList) into a recordset and then loops through the record set extracting the Row
information from each field, then transfers that information via the function fAppendListToData into the data table "tblData".
10. fCopyListToData puts the data from the list (tblList) into a recordset and then loops through the record set extracting the Row information
from each field, then transfers that information via the function fAppendListToData into the data table "tblData".
11. fCopyListToData puts the data from the list (tblList) into a recordset and then loops through the record set extracting the Row information
from each field, then transfers that information via the function fAppendListToData into the data table "tblData".
12. fCopyListToData puts the data from the list (tblList) into a recordset and then loops through the record set extracting the Row information
from each field, then transfers that information via the function fAppendListToData into the data table "tblData".