THEO TODMAN’S WEBSITE CODE PAGES



This Page provides a jumping-off point for the VBA Code that generates my Website.

Table of Code Documentation Location 31 (11 items)

Form_OpenCount_BookPapersFunctor_19Functor_21
Functor_22Functor_23Number_FormatAeon_Authors_Add
BooksToNotes_PrelimsCheckerJacks_Non_Prime.

To access information, click on one of the links in the table above.

Go to top of page




Source Code of: Aeon_Authors_Add
Procedure Type: Public Sub
Module: New Code
Lines of Code: 108
Go To End of This Procedure

Line-No. / Ref.Code Line
0001Public Sub Aeon_Authors_Add()
0002Dim rs As Recordset
0003Dim rsAuthors As Recordset
0004Dim rsAuthor_Parameter As Recordset
0005Dim strQuery As String
0006Dim strAuthor As String
0007Dim strAuthor_Saved As String
0008Dim Author As String
0009Dim Author_Reformat As String
0010Dim i As Integer
0011Dim j As Integer
0012Dim k As Integer
0013Dim x As Integer
0014Dim strMessage As String
0015Dim Output_Authors As Boolean
0016Dim Output_Old_Authors As Boolean
0017 strMessage = "Get ready to output Authors pages? Usually wait to output until we've output the Aeon note with 'Refresh Links', but this will maintain the Author_Parameter table."
0018If MsgBox(strMessage, vbYesNo + vbDefaultButton1) = vbYes Then
0019 Output_Authors = True
0020 strMessage = "Add all relevant Authors pages, including newly-loaded ones, to Author_Parameter table?"
0021 If MsgBox(strMessage, vbYesNo + vbDefaultButton1) = vbYes Then
0022 Output_Old_Authors = True
0023 Else
0024 Output_Old_Authors = False
0025 End If
0026Else
0027 Output_Authors = False
0028 Output_Old_Authors = False
0029End If
0030strAuthor_Saved = ""
0031' Clear & ready Author_Parameter Table
0032 strQuery = "DELETE * FROM Author_Parameter;"
0033DoCmd.RunSQL (strQuery)
0034 strQuery = "SELECT * FROM Author_Parameter;"
0035Set rsAuthor_Parameter = CurrentDb.OpenRecordset(strQuery)
0036' Select Aeon_Files rows with Authors encoded
0037 strQuery = "SELECT Aeon_Files.Author_Names FROM Aeon_Files WHERE (((Aeon_Files.Author_Names) Like ""*+A*"")) ORDER BY Aeon_Files.Author_Names;"
0038Set rs = CurrentDb.OpenRecordset(strQuery)
0039rs.MoveFirst
0040Do Until rs.EOF
0041 strAuthor = rs.Fields(0)
0042 If strAuthor <> strAuthor_Saved Then
0043 'Find the authors
0044 i = 1
0045 j = 1
0046 Do Until j = 0
0047 j = InStr(i, strAuthor, "A+")
0048 If j > 0 Then
0049 Author = Mid(strAuthor, i + 2, j - i - 2)
0050 'Check if on Author's Table
0051 strQuery = "SELECT Authors.Author_Name, Authors.Author_Name_Display FROM Authors WHERE (((Authors.Author_Name)=""" & Author & """));"
0052 Set rsAuthors = CurrentDb.OpenRecordset(strQuery)
0053 If rsAuthors.EOF Then
0054 Debug.Print Author
0055 Author_Reformat = Author
0056 x = InStr(Author_Reformat, "(")
0057 If x > 0 Then
0058 k = InStr(x, Author_Reformat, ")")
0059 If k > 0 Then
0060 Author_Reformat = Mid(Author_Reformat, x + 1, k - x - 1) & " " & Trim(Left(Author_Reformat, x - 1))
0061 End If
0062 End If
0063 'Load to Author's table
0064 rsAuthors.AddNew
0065 rsAuthors.Fields(0) = Author
0066 rsAuthors.Fields(1) = Author_Reformat
0067 rsAuthors.Update
0068 Set rsAuthors = Nothing
0069 'Add to Author_Parameter Table, ready for output of the Author pages
0070 rsAuthor_Parameter.AddNew
0071 rsAuthor_Parameter.Fields(0) = Author
0072 rsAuthor_Parameter.Update
0073 Else
0074 If Output_Old_Authors = True Then
0075 'Add to Author_Parameter Table, ready for output of the Author pages (existing authors need to have their pages updated)
0076 rsAuthor_Parameter.AddNew
0077 rsAuthor_Parameter.Fields(0) = Author
0078 On Error Resume Next
0079 rsAuthor_Parameter.Update
0080 End If
0081 End If
0082 i = j
0083 i = InStr(i, strAuthor, "+A")
0084 If i = 0 Then
0085 j = 0
0086 End If
0087 End If
0088 Loop
0089 End If
0090 strAuthor_Saved = strAuthor
0091 rs.MoveNext
0092Loop
0093If Output_Authors = True Then
0094 strMessage = "Actually output the Authors pages? Usually wait until we've output the Aeon note with 'Refresh Links'."
0095 If MsgBox(strMessage, vbYesNo + vbDefaultButton2) = vbYes Then
0096 'Output the Author pages
0097 strDataQuery = "Authors_List_Selected_Authors"
0098 strControlTable = "Authors"
0099 strOutputFileShort = "Author"
0100 strOutputFolder = "C:\Theo's Files\Websites\Theo's Website\Authors\"
0101 strOutputFile = ""
0102 CreateAuthorsWebPages ("Regen")
0103 End If
0104End If
0105OK = MsgBox("Authors added OK at " & Now(), vbOKOnly)
0106Set rs = Nothing
0107Set rsAuthor_Parameter = Nothing
0108End Sub

Procedures Calling This Procedure (Aeon_Authors_Add) Procedures Called By This Procedure (Aeon_Authors_Add) Tables / Queries / Fragments Directly Used By This Procedure (Aeon_Authors_Add) Go To Start of This Procedure
Go To Top of This Page
Link to VBA Code Control Page



Source Code of: BooksToNotes_Prelims
Procedure Type: Public Sub
Module: Testing
Lines of Code: 10

Line-No. / Ref.Code Line
0001Public Sub BooksToNotes_Prelims()
0002Dim strQuery As String
0003 strQuery = "DELETE * FROM Cross_Reference_Prelims;"
0004DoCmd.RunSQL (strQuery)
0005 strQuery = "BooksToNotes_Prelims_GEN"
0006DoCmd.OpenQuery (strQuery)
0007'Delete rows associated with Note 874 (Auto-Xref Test Note)
0008 strQuery = "DELETE * FROM Cross_Reference_Prelims WHERE Calling_ID = 874 AND Calling_Type = ""N"";"
0009DoCmd.RunSQL (strQuery)
0010End Sub

Procedures Calling This Procedure (BooksToNotes_Prelims) Tables / Queries / Fragments Directly Used By This Procedure (BooksToNotes_Prelims) Go To Top of This Page
Link to VBA Code Control Page



Source Code of: Checker
Procedure Type: Public Sub
Module: Testing
Lines of Code: 16

Line-No. / Ref.Code Line
0001Public Sub Checker()
0002Dim rs As Recordset
0003Dim i As Integer
0004Dim ifields As Integer
0005'Set rs = CurrentDb.OpenRecordset("TRANSFORM Sum([Year_Crosstab].[Hours ]) AS Hours SELECT Average_Plans.Project, Average_Plans.[Average This Qtr Plan] AS [Planned Weekly Hours], 0 AS [Planned QTD %age], Sum(0) AS [QTD Actual %], Round([Average YTD Plan],2) AS [Planned YTD %age], Sum(0) AS [YTD Actual %], Sum(0) AS [QTD Actual Hours], Sum(Year_Crosstab.Hours) AS [YTD Actual Hours] FROM Average_Plans LEFT JOIN Year_Crosstab ON Average_Plans.Project = Year_Crosstab.Group WHERE ((((Year_Crosstab.Period) >= ""2019-10"" And (Year_Crosstab.Period) <= ""2020-09"") Or (Year_Crosstab.Period) Is Null)) GROUP BY Average_Plans.Project, Average_Plans.[Average This Qtr Plan], Round([Average YTD Plan],2) ORDER BY Average_Plans.Project PIVOT Year_Crosstab.Period;")
0006 Set rs = CurrentDb.OpenRecordset("SELECT * FROM Project_Plans;")
0007rs.MoveFirst
0008ifields = rs.Fields.Count
0009Do Until rs.EOF
0010 For i = 0 To ifields - 1
0011 Debug.Print rs.Fields(i)
0012 Stop
0013 Next i
0014 rs.MoveNext
0015Loop
0016End Sub

Tables / Queries / Fragments Directly Used By This Procedure (Checker) Go To Top of This Page
Link to VBA Code Control Page



Source Code of: Count_BookPapers
Procedure Type: Public Function
Module: New Code
Lines of Code: 13

Line-No. / Ref.Code Line
0001Public Function Count_BookPapers(strDataQuery_Saved, Author, Medium)
0002Dim rs As Recordset
0003Dim strQuery As String
0004strQuery = "SELECT Count(" & strDataQuery_Saved & ".Title) AS CountOfTitle FROM " & strDataQuery_Saved & " GROUP BY " & strDataQuery_Saved & ".Author_Name, " & strDataQuery_Saved & ".Medium HAVING (((" & strDataQuery_Saved & ".Author_Name)=""" & Author & """) AND ((" & strDataQuery_Saved & ".Medium)=""" & Medium & """));"
0005Set rs = CurrentDb.OpenRecordset(strQuery)
0006If rs.EOF Then
0007 Count_BookPapers = 0
0008Else
0009 rs.MoveLast
0010 Count_BookPapers = rs.Fields(0)
0011End If
0012Set rs = Nothing
0013End Function

Go To Top of This Page
Link to VBA Code Control Page



Source Code of: Form_Open
Procedure Type: Private Sub
Module: Form_MainForm
Lines of Code: 13

Line-No. / Ref.Code Line
0001Private Sub Form_Open(Cancel As Integer)
0002Dim rsTableToRead As Recordset
0003 OK = Check_Database_Size()
0004Debug.Print Now() & " - Main Database size = " & Check_Database_Size & "Mb"
0005 Set rsTableToRead = CurrentDb.OpenRecordset("SELECT Archive_Reading_Lists, Archive_Printable_Versions, Document_Tables_Full, Document_Queries_Full FROM System_Parameters;")
0006rsTableToRead.MoveFirst
0007Archive_Reading_Lists = rsTableToRead.Fields(0).Value
0008Archive_Printable_Versions = rsTableToRead.Fields(1).Value
0009Document_Tables_Full = rsTableToRead.Fields(2).Value
0010Document_Queries_Full = rsTableToRead.Fields(3).Value
0011Full_Regen = False
0012Set rsTableToRead = Nothing
0013End Sub

Procedures Called By This Procedure (Form_Open) Tables / Queries / Fragments Directly Used By This Procedure (Form_Open) Go To Top of This Page
Link to VBA Code Control Page



Source Code of: Functor_19
Procedure Type: Public Function
Module: Functors
Lines of Code: 42
Go To End of This Procedure

Line-No. / Ref.Code Line
0001Public Function Functor_19(Note_ID, Note_Title, Note_Text)
0002'Add jump table and record counts for Aeon Note 1292
0003Dim rs As Recordset
0004Dim strQuery As String
0005Dim Papers_Read As String
0006Dim Papers_UnReadTotal As String
0007Dim Papers_UnRead(10) As Integer
0008Dim Note_Text_Local As String
0009Dim i As Integer
0010Note_Text_Local = Note_Text
0011 strQuery = "SELECT Aeon_Files.[Read?], Count(Aeon_Files.WebRef_ID) AS CountOfWebRef_ID FROM Aeon_Files WHERE (((Aeon_Files.Aeon_Note_ID) = 1292) And ((Aeon_Files.[Exclude?]) = False)) GROUP BY Aeon_Files.[Read?];"
0012Set rs = CurrentDb.OpenRecordset(strQuery)
0013If Not rs.EOF Then
0014 rs.MoveFirst
0015 Papers_Read = rs.Fields(1)
0016 OK = Number_Format(Papers_Read)
0017 rs.MoveLast
0018 Papers_UnReadTotal = rs.Fields(1)
0019 OK = Number_Format(Papers_UnReadTotal)
0020End If
0021 strQuery = "SELECT Aeon_Files.Priority, Count(Aeon_Files.WebRef_ID) AS CountOfWebRef_ID FROM Aeon_Files WHERE (((Aeon_Files.Aeon_Note_ID) = 1292) And ((Aeon_Files.[Read?]) = False) AND ((Aeon_Files.[Exclude?])=False)) GROUP BY Aeon_Files.Priority ORDER BY Aeon_Files.Priority;"
0022Set rs = CurrentDb.OpenRecordset(strQuery)
0023If Not rs.EOF Then
0024 rs.MoveFirst
0025 Do Until rs.EOF
0026 Papers_UnRead(rs.Fields(0)) = rs.Fields(1)
0027 rs.MoveNext
0028 Loop
0029End If
0030Note_Text_Local = "<br><CENTER><TABLE class = ""ReadingList"" WIDTH=1200><TR>"
0031Note_Text_Local = Note_Text_Local & "<TD class = ""BridgeLeft""> <a href=""#Off-Page_Link_Project_Note_1292_Intro""><B>Introduction</a></B></TD>"
0032Note_Text_Local = Note_Text_Local & "<TD class = ""BridgeLeft""> <a href=""#Off-Page_Link_Project_Note_1292_Read""><B>Papers Read</a>: </B>" & Papers_Read & "</TD>"
0033Note_Text_Local = Note_Text_Local & "<TD class = ""BridgeLeft""> <B>Papers Unread: " & Papers_UnReadTotal & "</B> &rarr; </TD>"
0034For i = 0 To 10
0035 If Papers_UnRead(i) > 0 Then
0036 Note_Text_Local = Note_Text_Local & "<TD class = ""BridgeLeft""> <a href=""#Off-Page_Link_Project_Note_1292_Pri_" & i & """><B>Pri " & i & "</B></a>: " & Papers_UnRead(i) & "</TD>"
0037 End If
0038Next i
0039Note_Text_Local = Note_Text_Local & "</TR></TABLE></CENTER><a name=""Off-Page_Link_Project_Note_1292_Intro""></a>"
0040Note_Text = Note_Text_Local
0041Functor_19 = "Yes"
0042End Function

Procedures Calling This Procedure (Functor_19) Procedures Called By This Procedure (Functor_19) Tables / Queries / Fragments Directly Used By This Procedure (Functor_19) Go To Start of This Procedure
Go To Top of This Page
Link to VBA Code Control Page



Source Code of: Functor_21
Procedure Type: Public Function
Module: Functors
Lines of Code: 128
Go To End of This Procedure

Line-No. / Ref.Code Line
0001Public Function Functor_21(strParameter, strTable)
0002'This function formats a web-table from a Cross-tab query
0003Dim rs As Recordset
0004Dim i As Integer
0005Dim j As Long
0006Dim k(100)
0007Dim iRows As Integer
0008Dim iCols As Integer
0009Dim strTable_Local As String
0010Dim strElement As String
0011Dim strCell As String
0012Dim strQuery As String
0013Dim strHeader As String
0014Select Case strParameter
0015 Case 1
0016 strQuery = "Cross_Reference_By_Type"
0017 Case 2
0018 strQuery = "Cross_Reference_Changes_By_Type"
0019 Case 3
0020 strQuery = "Oboe_Practice_Hours_List"
0021 Case Else
0022 Exit Function
0023End Select
0024strTable_Local = ""
0025j = 0
0026For i = 1 To 100
0027 k(i) = 0
0028Next i
0029Set rs = CurrentDb.OpenRecordset(strQuery)
0030If rs.EOF Then
0031 Debug.Print Now(); "Cross_Tab_Table_GEN : No table to print"
0032 Functor_21 = "No"
0033 Exit Function
0034Else
0035 rs.MoveLast
0036 iRows = rs.RecordCount
0037 iCols = rs.Fields.Count
0038 rs.MoveFirst
0039End If
0040'Set up Table Header
0041Select Case strParameter
0042 Case 3
0043 strElement = "<table width=1500 class = ""Bridge"">"
0044 Case Else
0045 strElement = "<table width=900 class = ""Bridge"">"
0046End Select
0047strTable_Local = strTable_Local & strElement
0048'Set up Table Headings
0049strElement = "<tr>"
0050For i = 1 To iCols
0051 strCell = rs.Fields(i - 1).Name
0052 strElement = strElement & "<th>" & strCell & "</th>"
0053Next i
0054If strParameter <> 3 Then
0055 strElement = strElement & "<th>TOTAL</th>"
0056End If
0057strElement = strElement & "</tr>"
0058strHeader = strElement
0059strTable_Local = strTable_Local & strElement
0060'Set up Table Rows
0061strElement = ""
0062Do Until rs.EOF
0063 strElement = strElement & "<tr>"
0064 j = 0
0065 For i = 1 To iCols
0066 If i = 1 Then
0067 strCell = rs.Fields(0)
0068 strElement = strElement & "<th>" & strCell & "</th>"
0069 Else
0070 strCell = rs.Fields(i - 1) & ""
0071 If strCell = "" Then
0072 strCell = "&nbsp;"
0073 Else
0074 j = j + Val(strCell)
0075 k(i) = k(i) + Val(strCell)
0076 If strParameter <> 3 Then
0077 OK = Number_Format(strCell)
0078 End If
0079 End If
0080 strElement = strElement & "<td format="","">" & strCell & "</td>"
0081 End If
0082 Next i
0083 'Row Total
0084 strCell = j
0085 If strParameter <> 3 Then
0086 OK = Number_Format(strCell)
0087 strElement = strElement & "<th>" & strCell & "</th></tr>"
0088 End If
0089 k(iCols + 1) = k(iCols + 1) + j
0090 rs.MoveNext
0091Loop
0092strTable_Local = strTable_Local & strElement
0093'Set up Total Line
0094strElement = "<tr><th>TOTAL</th>"
0095For i = 2 To iCols + 1
0096 strCell = k(i)
0097 If strParameter <> 3 Then
0098 OK = Number_Format(strCell)
0099 End If
0100 If strCell = 0 Then
0101 strCell = "&nbsp;"
0102 End If
0103 If strParameter = 3 Then
0104 If i = iCols + 1 Then
0105 Else
0106 If i < 5 Then
0107 strElement = strElement & "<th>" & "&nbsp;" & "</th>"
0108 Else
0109 strElement = strElement & "<th>" & strCell & "</th>"
0110 End If
0111 End If
0112 Else
0113 strElement = strElement & "<th>" & strCell & "</th>"
0114 End If
0115Next i
0116strElement = strElement & "<tr>"
0117strTable_Local = strTable_Local & strElement
0118'Set up Table Footer
0119If strParameter = 3 Then
0120 strTable_Local = strTable_Local & strHeader 'Repeat the column headers
0121End If
0122strElement = "</table>"
0123strTable_Local = strTable_Local & strElement
0124'Tidy up and exit
0125Functor_21 = "Yes"
0126strTable = strTable_Local
0127Set rs = Nothing
0128End Function

Procedures Calling This Procedure (Functor_21) Procedures Called By This Procedure (Functor_21) Tables / Queries / Fragments Directly Used By This Procedure (Functor_21) Go To Start of This Procedure
Go To Top of This Page
Link to VBA Code Control Page



Source Code of: Functor_22
Procedure Type: Public Function
Module: Functors
Lines of Code: 51
Go To End of This Procedure

Line-No. / Ref.Code Line
0001Public Function Functor_22(strParameter, strList)
0002'This function formats a list (together with surrounding narrative) from a query
0003Dim rs As Recordset
0004Dim strList_Local As String
0005Dim strElement As String
0006Dim strCell As String
0007Dim strQuery As String
0008Select Case strParameter
0009 Case 1
0010 strQuery = "Cross_Reference_By_Year"
0011 strElement = "However, there are (as of " & Now() & ", using +CFunctor_22C+ & query +QCross_Reference_By_YearQ+) the following counts of records on the table with timestamps in the years below:- "
0012 Case 2
0013 strQuery = "Cross_Reference_Changes_By_Year"
0014 strElement = ""
0015 Case 3
0016 DoCmd.OpenQuery ("Functor_Descriptions_GEN")
0017 strQuery = "Functor_Descriptions_List"
0018 strElement = ""
0019 Case 4
0020 strQuery = "Cross_Reference_Changes_By_Month"
0021 strElement = ""
0022End Select
0023Set rs = CurrentDb.OpenRecordset(strQuery)
0024strList_Local = ""
0025If rs.EOF Then
0026 Debug.Print Now(); "Functor_22: Option " & strParameter & " - No list to print"
0027 Functor_22 = "No"
0028 Exit Function
0029Else
0030 rs.MoveFirst
0031End If
0032'Set up List Header
0033strElement = strElement & "|##|"
0034strList_Local = strList_Local & strElement
0035strElement = ""
0036Do Until rs.EOF
0037 strElement = strElement & "|.|"
0038 strElement = strElement & "<b>" & rs.Fields(0) & "</b>: "
0039 strCell = rs.Fields(1)
0040 OK = Number_Format(strCell)
0041 strElement = strElement & strCell
0042 rs.MoveNext
0043Loop
0044strList_Local = strList_Local & strElement
0045'Set up End List
0046strElement = "|##|"
0047strList_Local = strList_Local & strElement
0048Functor_22 = "Yes"
0049strList = strList_Local
0050Set rs = Nothing
0051End Function

Procedures Calling This Procedure (Functor_22) Procedures Called By This Procedure (Functor_22) Tables / Queries / Fragments Directly Used By This Procedure (Functor_22) Go To Start of This Procedure
Go To Top of This Page
Link to VBA Code Control Page



Source Code of: Functor_23
Procedure Type: Public Function
Module: Functors
Lines of Code: 83
Go To End of This Procedure

Line-No. / Ref.Code Line
0001Public Function Functor_23(Note_ID, strOption, strValue)
0002'This function returns a value (together with surrounding narrative) from a query
0003Dim rs As Recordset
0004Dim strValue_Local As String
0005Dim strElement As String
0006Dim strMsg As String
0007Dim strQuery As String
0008Select Case strOption
0009 Case "1"
0010 strQuery = "Dud_Cross_References_This_Year"
0011 Case "2"
0012 strQuery = "Cross_Reference_MaxID"
0013 Case "3"
0014 strQuery = "SELECT Count(Cross_Reference_Changes.ID) AS CountOfID FROM Cross_Reference_Changes;"
0015 Case "4"
0016 strQuery = "SELECT Website_Regen_Control.Regen_Mins, Website_Regen_Control.Last_Run, Website_Regen_Control.Division FROM Website_Regen_Control WHERE (((Website_Regen_Control.Division)=""Paper_Abstract_Ranges""));"
0017 Case "5"
0018 strQuery = "SELECT Website_Regen_Control.Regen_Mins, Website_Regen_Control.Last_Run, Website_Regen_Control.Division FROM Website_Regen_Control WHERE (((Website_Regen_Control.Division)=""Author_Letters""));"
0019 Case "6"
0020 strQuery = "SELECT Website_Regen_Control.Regen_Mins, Website_Regen_Control.Last_Run, Website_Regen_Control.Division FROM Website_Regen_Control WHERE (((Website_Regen_Control.Division)=""BookPaperAbstract_Ranges""));"
0021 Case "7"
0022 strQuery = "SELECT Website_Regen_Control.Regen_Mins, Website_Regen_Control.Last_Run, Website_Regen_Control.Division FROM Website_Regen_Control WHERE (((Website_Regen_Control.Division)=""Note_Regen_Ranges""));"
0023 Case "8"
0024 strQuery = "SELECT Website_Regen_Control.Regen_Mins, Website_Regen_Control.Last_Run, Website_Regen_Control.Division FROM Website_Regen_Control WHERE (((Website_Regen_Control.Division)=""Note_Archive_Regen_Ranges""));"
0025 Case "9"
0026 strQuery = "SELECT * FROM Oboe_Latest_Lesson;"
0027 Case "10"
0028 strQuery = "SELECT BookPaperControl.Time_To_Regenerate, BookPaperControl.Latest_Update FROM BookPaperControl WHERE (((BookPaperControl.[ID])=""Auto_Reference_Notes_Regen""));"
0029 Case Else
0030 Debug.Print Now(); "Note: " & Note_ID & ". Functor_23 : Invalid Option : " & strOption
0031 Functor_23 = "No"
0032 Exit Function
0033End Select
0034Set rs = CurrentDb.OpenRecordset(strQuery)
0035strValue_Local = ""
0036If rs.EOF Then
0037 Debug.Print Now(); "Note: " & Note_ID & ". Functor_23 : No item to print (Option = " & strOption & ")"
0038 Functor_23 = "No"
0039 Exit Function
0040End If
0041Select Case strOption
0042 Case "1"
0043 rs.MoveLast
0044 strElement = rs.Fields(1)
0045 If rs.Fields(0) <> rs.Fields(2) Then
0046 strElement = 0
0047 End If
0048 If strElement = 0 Then
0049 strElement = "no"
0050 strMsg = "encouraging."
0051 Else
0052 strMsg = "<b>worrying. <u>Investigate</u>!</b>"
0053 Debug.Print Now(); "Note: " & Note_ID & ". Functor_23, Option 1 : Non-zero value printed - Investigate!"
0054 End If
0055 strValue_Local = strElement & " record" & IIf(Val(strElement) > 1, "s", "") & " for " & rs.Fields(2) & " prior to the " & rs.Fields(3) & " regeneration, which is " & strMsg
0056 Case "2"
0057 rs.MoveFirst
0058 strElement = rs.Fields(0)
0059 OK = Number_Format(strElement)
0060 strValue_Local = Now() & " it is " & strElement & " - but it's taken " & Year(Now) - 2015
0061 Case "3"
0062 rs.MoveFirst
0063 strElement = rs.Fields(0)
0064 OK = Number_Format(strElement)
0065 strValue_Local = strElement & " rows, as of " & Left(Now(), 10) & ", "
0066 Case "4", "5", "6", "7", "8", "10"
0067 rs.MoveFirst
0068 strElement = rs.Fields(0)
0069 If strElement >= 60 Then
0070 strElement = Round(strElement / 60, 2) & " hours"
0071 Else
0072 strElement = strElement & " minutes"
0073 End If
0074 strElement = strElement & " on " & Left(rs.Fields(1), 10)
0075 strValue_Local = strElement
0076 Case "9"
0077 rs.MoveFirst
0078 strValue_Local = rs.Fields(0)
0079End Select
0080Functor_23 = "Yes"
0081strValue = strValue_Local
0082Set rs = Nothing
0083End Function

Procedures Calling This Procedure (Functor_23) Procedures Called By This Procedure (Functor_23) Tables / Queries / Fragments Directly Used By This Procedure (Functor_23) Go To Start of This Procedure
Go To Top of This Page
Link to VBA Code Control Page



Source Code of: Jacks_Non_Prime
Procedure Type: Public Sub
Module: Testing
Lines of Code: 36
Go To End of This Procedure

Line-No. / Ref.Code Line
0001Public Sub Jacks_Non_Prime()
0002'Prove that 2^10 + 5^12 is non-prime
0003'The program shows:-
0004'... The number is 244,141,649 = 14657 x 16657
0005'... Max Long is 2,147,483,647, so didn't need LongLong
0006Dim Non_Prime As LongLong
0007Dim Non_Prime_Temp As LongLong
0008Dim Non_Prime_Sqrt As Integer
0009Dim i As Integer
0010Non_Prime_Temp = 1
0011For i = 1 To 10
0012 Non_Prime_Temp = Non_Prime_Temp * 2
0013Next i
0014Debug.Print Non_Prime_Temp
0015Non_Prime = Non_Prime_Temp
0016Non_Prime_Temp = 1
0017For i = 1 To 12
0018 Non_Prime_Temp = Non_Prime_Temp * 5
0019Next i
0020Debug.Print Non_Prime_Temp
0021Non_Prime = Non_Prime + Non_Prime_Temp
0022Debug.Print Non_Prime
0023Non_Prime_Sqrt = Non_Prime ^ 0.5
0024Debug.Print Non_Prime_Sqrt
0025Non_Prime_Sqrt = Non_Prime_Sqrt / 2 + 1
0026For i = 1 To Non_Prime_Sqrt
0027 Non_Prime_Temp = Non_Prime Mod (2 * i + 1)
0028 If Non_Prime_Temp = 0 Then
0029 Debug.Print 2 * i + 1
0030 Non_Prime_Temp = Non_Prime / (2 * i + 1)
0031 Debug.Print Non_Prime_Temp
0032 Non_Prime_Temp = Non_Prime_Temp * (2 * i + 1)
0033 Debug.Print Non_Prime_Temp
0034 End If
0035Next i
0036End Sub

Go To Start of This Procedure
Go To Top of This Page
Link to VBA Code Control Page



Source Code of: Number_Format
Procedure Type: Public Function
Module: New Code
Lines of Code: 39
Go To End of This Procedure

Line-No. / Ref.Code Line
0001Public Function Number_Format(strNumber_Sent)
0002Dim strNumber_Local As String
0003Dim Digit_Table(20) As String
0004Dim i As Integer
0005Dim j As Integer
0006Dim iLen_Number As Integer
0007'This function inserts commas into a number sent ...
0008'I may get it to do further functions in due course
0009' .... I couldn't find an HTML format command to do this
0010' .... but there must be a VBA built-in function?
0011strNumber_Local = Trim(strNumber_Sent)
0012If Not IsNumeric(strNumber_Local) Then
0013 Exit Function
0014End If
0015iLen_Number = Len(strNumber_Local)
0016For i = 1 To 20
0017 Digit_Table(i) = ""
0018Next i
0019'Add the commas (in reverse)
0020j = 1
0021For i = 1 To iLen_Number
0022 Digit_Table(j) = Mid(strNumber_Local, iLen_Number + 1 - i, 1)
0023 j = j + 1
0024 If i Mod 3 = 0 Then
0025 Digit_Table(j) = ","
0026 j = j + 1
0027 End If
0028Next i
0029'Remove trailing comma
0030If Digit_Table(j - 1) = "," Then
0031 Digit_Table(j - 1) = ""
0032End If
0033strNumber_Local = ""
0034For i = 1 To j - 1
0035 strNumber_Local = strNumber_Local & Digit_Table(j - i)
0036Next i
0037'Exit
0038strNumber_Sent = strNumber_Local
0039End Function

Procedures Calling This Procedure (Number_Format) Go To Start of This Procedure
Go To Top of This Page
Link to VBA Code Control Page



© Theo Todman, June 2007 - Sept 2020. Please address any comments on this page to theo@theotodman.com. File output:
Website Maintenance Dashboard
Return to Top of this Page Return to Theo Todman's Philosophy Page Return to Theo Todman's Home Page