diff --git a/README.md b/README.md index c89e8e9..bffc1fe 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,14 @@ Support Sigma Coding ## Overview -Howdy! My name is [Alex](https://www.linkedin.com/in/alex-reed/), and if you're like me, you enjoy the world of programming. Or maybe you were like me a few years ago and are beginning to take your first step into this exciting world. The GitHub repository you're currently contains almost all of the code you find on my YouTube channel Sigma Coding. Feel free to clone, download or branch this repository so you can leverage the code I share in my channel. +Howdy! My name is [Alex](https://www.linkedin.com/in/alex-reed/), and if you're like me, you +enjoy the world of programming. Or maybe you were like me a few years ago and are beginning +to take your first step into this exciting world. The GitHub repository you're currently contains +almost all of the code you find on my YouTube channel Sigma Coding. Feel free to clone, +download or branch this repository so you can leverage the code I share in my channel. -Because I cover so many different langages on my YouTube channel, I dedicate a folder to each specific lanaguge. Right now, I cover the following lanagues on my channel: +Because I cover so many different langages on my YouTube channel, I dedicate a folder to each +specific lanaguge. Right now, I cover the following lanagues on my channel: - [Python](https://github.com/areed1192/sigma_coding_youtube/tree/master/python) - [VBA](https://github.com/areed1192/sigma_coding_youtube/tree/master/vba) @@ -48,32 +53,46 @@ Because I cover so many different langages on my YouTube channel, I dedicate a f - [M Langauge (Used for Power Query & Power BI)](https://github.com/areed1192/sigma_coding_youtube/tree/master/m%20language) - [T SQL](https://github.com/areed1192/sigma_coding_youtube/tree/master/t%20sql) -This list is continuously changing, and I do my best to make tutorials engaging, exciting, and most importantly, easy to follow! +This list is continuously changing, and I do my best to make tutorials engaging, exciting, +and most importantly, easy to follow! ## Topics -Now, I cover a lot of topics on my channel and as much I would like to list them all I don't want to overload with you a bunch of information. Here is a list of some of my more popular topics: +Now, I cover a lot of topics on my channel and as much I would like to list them all I don't +want to overload with you a bunch of information. Here is a list of some of my more popular topics: - **Python:** - **Win32COM** The Win32COM library allows us to control the VBA object model from Python. - - **TD Ameritrade API** The TD Ameritrade API allows us to stream real-time quote data and execute trades from Python. - - **Interactive Brokers API** The TD Ameritrade API allows us to stream real-time quote data and execute trades from Python. - - **Machine Learning** I cover different machine learning models ranging from regression to classification. - - **Pythonnet** Pythonnet is used to connect Python to something called the CLR (Common Language Runtime) which gives us access to more Windows speicific libraries. + - **TD Ameritrade API** The TD Ameritrade API allows us to stream real-time quote data and + execute trades from Python. + - **Interactive Brokers API** The TD Ameritrade API allows us to stream real-time quote data + and execute trades from Python. + - **Machine Learning** I cover different machine learning models ranging from regression to + classification. + - **Pythonnet** Pythonnet is used to connect Python to something called the CLR (Common Language + Runtime) which gives us access to more Windows speicific libraries. - **VBA:** - - **PowerPoint VBA** This series covers interacting with PowerPoint objects using VBA, topics like linking OLE objects and formatting slides. - - **Word VBA** With Word VBA, we see how to manipulate different documents and change the underlying format in them. - - **Outlook VBA** In Outlook, we work with email objects and account information. + - **Access VBA** In Access, we can store large amounts of data. With Access, we will see how to + create tables, query existing tables, and even importing and exporting data to and from access. - **Excel VBA** In Excel, we do an awful lot even working with non-standard libraries like ADODB. + - **Outlook VBA** In Outlook, we work with email objects and account information. + - **PowerPoint VBA** This series covers interacting with PowerPoint objects using VBA, topics like + linking OLE objects and formatting slides. + - **Publisher VBA** In Publisher, we explore how to create fliers and other media documents for + advertising. + - **Word VBA** With Word VBA, we see how to manipulate different documents and change the underlying + format in them. - **JavaScript:** - **Office API** Learn how to use the new JavaScript API for Microsoft Office. - - **Excel API** The Excel API focuses just on the API for Microsoft Excel and the object model associated with it. - - **Word API** The Word API focuses just on the API for Microsoft Word and the object model associated with it. + - **Excel API** The Excel API focuses just on the API for Microsoft Excel and the object + model associated with it. + - **Word API** The Word API focuses just on the API for Microsoft Word and the object model + associated with it. - **TSQL:** @@ -82,11 +101,14 @@ Now, I cover a lot of topics on my channel and as much I would like to list them ## Resources -If you ever have a question, would like to suggest a topic, found a mistake or just want some input for a project you can always email me at **coding.sigma@gmail.com**. Additionally, you can find dedicated folders in the repository for resources like documentation. +If you ever have a question, would like to suggest a topic, found a mistake or just want some +input for a project you can always email me at **coding.sigma@gmail.com**. Additionally, you +can find dedicated folders in the repository for resources like documentation. ## Links To Other Respositories -Some of my projects are so large that they have dedicated repositories for them. Here is a list of repositiories of my other repositiories: +Some of my projects are so large that they have dedicated repositories for them. Here is a +list of repositiories of my other repositiories: - [TD Ameritrade API Client For Python](https://github.com/areed1192/td-ameritrade-python-api) - [Interactive Brokers API Client For Python](https://github.com/areed1192/interactive-broker-python-api) @@ -97,10 +119,15 @@ Some of my projects are so large that they have dedicated repositories for them. ## Support the Channel **Patreon:** -If you like what you see! Then Help support the channel and future projects by donating to my **[Patreon Page](https://www.patreon.com/sigmacoding)**. I'm always looking to add more content for individuals like yourself, unfortuantely some of the APIs I would require me to pay monthly fees. +If you like what you see! Then Help support the channel and future projects by donating to +my **[Patreon Page](https://www.patreon.com/sigmacoding)**. I'm always looking to add more +content for individuals like yourself, unfortuantely some of the APIs I would require me to +pay monthly fees. **Hire Me:** If you have a project, you think I can help you with feel free to reach out at [coding.sigma@gmail.com](mailto:coding.sigma@gmail.com?subject=[GitHub]%20Project%20Proposal) or fill out the [contract request form](https://forms.office.com/Pages/ResponsePage.aspx?id=ZwOBErInsUGliXx0Yo2VfcCSWZSwW25Es3vPV2veU0pUMUs5MUc2STkzSzVQMFNDVlI5NjJVNjREUi4u) **Disclosures:** -I am a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to **Amazon.com**. Full Disclosure: I will earn a commission if you purchase from the Shop Amazon link, more details are provided below. +I am a participant in the Amazon Services LLC Associates Program, an affiliate advertising program +designed to provide a means for sites to earn advertising fees by advertising and linking to **Amazon.com**. +Full Disclosure: I will earn a commission if you purchase from the Shop Amazon link, more details are provided below. diff --git a/python/python-vba/Lesson 11 - Calling Macros From Win32COM.py b/python/python-vba/Lesson 11 - Calling Macros From Win32COM copy.py similarity index 99% rename from python/python-vba/Lesson 11 - Calling Macros From Win32COM.py rename to python/python-vba/Lesson 11 - Calling Macros From Win32COM copy.py index 49820e4..9d32f1b 100644 --- a/python/python-vba/Lesson 11 - Calling Macros From Win32COM.py +++ b/python/python-vba/Lesson 11 - Calling Macros From Win32COM copy.py @@ -44,4 +44,4 @@ # Cell1.Value = 3000 # Cell2.Value = 4000 -# End Sub +# End Sub \ No newline at end of file diff --git a/vba/vba-access/query-definitions.vbs b/vba/vba-access/query-definitions.vbs new file mode 100644 index 0000000..8fbf3bf --- /dev/null +++ b/vba/vba-access/query-definitions.vbs @@ -0,0 +1,110 @@ +Option Compare Database + +Sub WorkWithQueries() + +'Declare our variables. +Dim AccessApp As Application +Dim AccessDatabase As Database +Dim AccessTable As TableDef +Dim AccessQuery As QueryDef +Dim AccessRecord As Recordset +Dim AccessRecordClone As Recordset +Dim QueryDefName As String + +'Grab the access application. +Set AccessApp = Application + +'Grab the Current Database in our application. +Set AccessDatabase = AccessApp.CurrentDb + +QueryDefName = "PullStockPricesTest" + +'Call the `IsInCollection` to see if the QueryDefinition Object Exists. +If IsInCollection(ObjectName:=QueryDefName, CollectionToCheck:=AccessDatabase.QueryDefs) = False Then + + 'If it doesn't create a new query definition. + Set AccessQuery = AccessDatabase.CreateQueryDef(Name:=QueryDefName, SQLText:="SELECT * FROM StockPrices") + + 'Refresh the QueryDefs Collection. + AccessDatabase.QueryDefs.Refresh + + 'Refresh the main Database Window. + AccessApp.RefreshDatabaseWindow + +Else + + 'If it does exist, then grab it from the query definitions collection. + Set AccessQuery = AccessDatabase.QueryDefs(QueryDefName) + +End If + +'Grab when it was last updated. +Debug.Print AccessQuery.LastUpdated + +'Grab the SQL Command. +Debug.Print AccessQuery.SQL + +'We can even update the SQL Statement after creating a Def. +AccessQuery.SQL = "SELECT * FROM StockPrices ORDER BY date DESC" + +'Is it Updatable? +Debug.Print AccessQuery.Updatable + +'Once you've defined the query you can open a new recordset. +Set AccessRecord = AccessQuery.OpenRecordset + +'Print out the number of records. +Debug.Print "There are " + CStr(AccessRecord.RecordCount) + " records." + +'Start working with the recordset object. +With AccessRecord + + 'As long as their is a record keep going. + Do Until .EOF + + 'Print out the first column. + Debug.Print ![Date] + Debug.Print ![Close] + + 'VERY IMPORTANT!!!! IF YOU MISS THIS YOU WILL HAVE A NEVER ENDING LOOP + .MoveNext + + Loop + +End With + +'Clone the Record. +Set AccessRecordClone = AccessRecord.Clone + Debug.Print "Cloned Record Count is: " + CStr(AccessRecordClone.RecordCount) + +'Close the Recordset object. +AccessRecord.Close + +End Sub + + +Function IsInCollection(ObjectName As String, CollectionToCheck As Object) + +'Declare Variable. +Dim CollectionObject As Object +Dim WasFound As Boolean + +'Loop through the "Collection". +For Each CollectionObject In CollectionToCheck + + 'If the Name matches, it means we have a match. + If CollectionObject.Name = ObjectName Then + WasFound = True + End If + +Next + +'If it was found we are good. +If WasFound <> True Then + WasFound = False +End If + +'Otherwise we don't have a match. +IsInCollection = WasFound + +End Function