My sites include references with codes so you do not waste time copying and pasting for nothing.
You do not need to know anything about references to use them, except which ones you need! You only select them once for each database and you are done with them.
To use my codes, you mostly need VBA, Access and DAO. I like code that uses only these references because the more references you use, the slower the database and the higher the risk for problems. One problem is ambiguity.
If you use both DAO and ADO in your code, you must disambiguate. This means each time you declare a recordset, you have to precede it with DAO or ADO like this:
DIM rs as DAO.RecordsetIf you do not disambiguate, you risk data corruption and other problems.
DIM rs as ADO.Recordset
You may notice that I do disambiguate because I do not know if you are already using ADO in your database.
Microsoft® Access includes VBA and Access but you will probably have to select DAO. I use Microsoft® Access 2002 and that version uses the Microsoft DAO 3.6 Object Library. Your version may use a different DAO library but you will recognize it by the DAO in the name.
Microsoft DAO 3.6 Object Library is not included by default in Microsoft Access 2000 or Microsoft Access 2002. Therefore, you must select it from the References window.
Your Visual Basic Editor may not look exactly like the window below but no matter.
Notice the highlighted x in the code in the module window. Microsoft® Access has displayed an error message. I purposely did not define the variable to create this error and stop the code for you.
After clicking OK on the error message, Visual Basic highlights the error line in yellow.
You cannot access References from the Tools menu while Visual Basic is stalled like this. References will be grayed-out and inaccessible as illustrated below.
You must use the Reset button as illustrated below.
Then you can access the References menu:
Now you can check off any references from the list of references needed to run the code:
The References I use may not look exactly like the references available to you. For example, look at all the Microsoft ActiveX Data Objects Libraries below. You may only choose one or Visual Basic will display an error message. Choose the Reference that most closely matches the one you are looking for.
Try to choose codes that use the same references rather than adding new ones. This assumes that any developers working on complicated databases are certainly not reading a post on how to select references.
If you are at the point in your learning where you are reading about references, then keeping it simple is also where you want to be.
Do you like this post? Please link back to this article by copying one of the codes below.URL: HTML link code: BB (forum) link code: