Code Colors Like In VB Editor

@MickJav
If you use an installer, you can indeed specify where files will be installed.
However, I haven't watched the video yet and its a few years since I created any add-ins, but IIRC isn't the location built in to the ACCDA setup based on USysRegInfo?
 
@MickJav
its a few years since I created any add-ins, but IIRC isn't the location built in to the ACCDA setup based on USysRegInfo?

Colin, I don't know how they used to work because I've only started creating add-ins about a year ago. In the usysRegInfo table, |ACCDIR\ specifies the add-in directory. If an add-in is "uninstalled" in Access, the accda file is still in that folder. For me, that is
C:\Users\MyUsername\AppData\Roaming\Microsoft\AddIns

If the file is somewhere else, Access copies it to that location when the add-in is installed.
 
When I'm ready for a test it, I'll convert it to a accda then move the folder to that location I have a link manager that can relink tables, I may have to play with the default loacation by actually giving it one :D

I'm also using my Style manager which uses some images for the preferences but If need be I can loss them they are just a look pretty thing Anyway

I've attached a couple of images showing the main code window I'm neally ready to start adding some code which I'll need for the next stage the tree view

I've kept it to a singl screen where I can.
 

Attachments

  • 2020-04-19.png
    2020-04-19.png
    59.5 KB · Views: 125
  • 2020-04-19 (1).png
    2020-04-19 (1).png
    39.1 KB · Views: 134
Mick, you're going to link tables in your add-in? That makes the add-in dependent on something else. Not saying its wrong, just wondering why
 
It's a database of code it'll link to a accdb backend otherwise the front end will end up very large as I'm using rich text large text fields in two places
 
It's a database of code it'll link to a accdb backend otherwise the front end will end up very large as I'm using rich text large text fields in two places

oh, ok. Here is some code I use to create a scratch database and link to a table in it. What is missing is the code to create the table. you could have the structure for that in your add-in, and export to the database you create for storing your big data -- be sure to name it something different than the template table you use to create it ;)

Rich (BB code):
' instead of bloating the FE with temporary tables,
'     make another BE and link to its tables.
' use the IN clause to specify an external database for make-table queries.
' If running SQL in code, to run in an external database:
'      With db ' where db is your database object
'            .Execute sSql 'where sSQL is the SQL statement to run
'            nNumRecs = .RecordsAffected 'where nNumRecs is a long integer
'      End With

Function CreateADatabase(psDatabaseName As String) As String
's4p
   'RETURN
   '  path and filename of created database
   'CALLS
   '  GetDatabaseName
  
   CreateADatabase = ""
  
   Dim sPathFileDatabase As String

   sPathFileDatabase = GetDatabaseName(psDatabaseName)
  
   '---------------------- create a new database

   'make a blank database
   DBEngine.CreateDatabase sPathFileDatabase, dbLangGeneral
  
   CreateADatabase = sPathFileDatabase
  
End Function

Function GetDatabaseName(psDatabaseName As String) As String
's4p
   'RETURN
   '  path\file of a specified database name
  
   Dim sPathFileDatabase As String
  
   If InStr(psDatabaseName, "\") > 0 Then
      'if path was specified, use it
      sPathFileDatabase = psDatabaseName
   Else
      'if no path specified, put database in current path
      sPathFileDatabase = CurrentProject.Path & "\" & psDatabaseName
   End If
  
   'add extension if not specified
   If Right(sPathFileDatabase, 6) <> ".accdb" Then
      sPathFileDatabase = sPathFileDatabase & ".accdb"
   End If

   GetDatabaseName = sPathFileDatabase

End Function

Function Link2TableOtherDatabase(psDatabaseName As String _
   , psTablename As String)
's4p
'When you are using Make Table and Append queries,
'use the optional IN clause to specify the path and filename of an external database.
'Then use this procedure to link to the table

   'CALLS
   '  GetDatabaseName
   '  DropTheTable
  
   Dim sPathFileDatabase As String

   Dim db As DAO.Database _
      , tdf As DAO.TableDef

   sPathFileDatabase = GetDatabaseName(psDatabaseName)

   'set db to be the current database
   Set db = CurrentDb

   'if table is already in the current database, delete it
   'might want to check the tabledef Connect property first
   'to make sure it is a linked table!
   Call DropTheTable(psTablename)

   'link to table
   With db
      Set tdf = .CreateTableDef(psTablename)
      tdf.Connect = ";Database=" & sPathFileDatabase
      tdf.SourceTableName = psTablename
      .TableDefs.Append tdf
      .TableDefs.Refresh
   End With

   'release object variables
   Set tdf = Nothing
   Set db = Nothing
End Function

Private Sub DropTheTable( _
   sTablename As String _
   , Optional pdb As DAO.Database _
   )
's4p
'Delete a table
'if the table is not there to delete, no error is returned
'another database may be passed

    Dim sName As String
    Dim db As DAO.Database
  
    On Error GoTo Proc_Err
   
    If pdb Is Nothing Then
      Set db = CurrentDb
   Else
      Set db = pdb
   End If
  
    'See if the table is there
    sName = db.TableDefs(sTablename).Name
  
    'If no error then table is there -- delete it
    With db
      .Execute "DROP TABLE [" & sTablename & "];"
      .TableDefs.Refresh
   End With
   DoEvents
  
Proc_Exit:
   On Error Resume Next
    Exit Sub
  
Proc_Err:

    Select Case Err.Number
      Case 3265 'Table does not exist
      Case Else
         MsgBox Err.Description, , _
           "ERROR " & Err.Number _
           & "   DropTheTable"
   End Select
  
   Resume Proc_Exit
   Resume
  
End Sub
 
Last edited:
ps, Mick, in your code, when you want to reference the add-in database, it is CodeDb. CurrentDb is the database you are working in.
 
Thanks Now You told Me remember Will Set A Global maybe

thanks
 
Colin, I don't know how they used to work because I've only started creating add-ins about a year ago. In the usysRegInfo table, |ACCDIR\ specifies the add-in directory. If an add-in is "uninstalled" in Access, the accda file is still in that folder. For me, that is
C:\Users\MyUsername\AppData\Roaming\Microsoft\AddIns

If the file is somewhere else, Access copies it to that location when the add-in is installed.

Thanks for confirming. I did recall correctly!
I remember using the attached link as a starting point some years ago http://www.databasedev.co.uk/access-add-ins.html
 
So looking at that it puts the accda in the addins folder so I wont be able to us currentapp path I'll have to go old skool
 
But thinking about it all the linking to the data file act can be done before installing it as an addin
 
I'll just use your video as it is intended for anybody to use the tables and images can be connected to the storage folder before it is enabled
 
Mick, you can link tables to the add-in. I did some experimenting, storing a template table in the add-in and then exporting it to a new database, then linking. It works as long as the add-in wasn't an add-in yet. Once it was running as an add-in, TransferDatabase didn't work because "Microsoft Access" wouldn't work for the parameter and I didn't know how then to refer to the add-in. DAO could be used to create the external table instead. Then the add-in can link to it.
 
I've seen that databasedev link before, but never worked with my own addin. I watched Crystal's video, and a couple of others(youtube) and managed to create 1 as an experiment to undertand the process that seems to work. I have also been reading Acc97 handbook, and a Access2010 book to try and refresh the difference in a Library database, Builder, Wizard and AddIn - without much success, but I've managed 25+ yrs without knowing so nothing urgent here. Perhaps it's just me, but it is somewhat surprising that many of these 2.5" thick tomes have little meat.
Thanks Crystal for the video. And I have subscribed an do watch your youtube videos.
 
Thanks Crystal I did think is would work what I'll do is install my copy then see if the link manager works, I can aways uninstall it.

as long as the folder holding the datafile/images isn't moved there shouldn't be any problems.

Not Quite ready to unstall a test as Want to get a bit more done on the u.i. First
 
Just got the field validation and categories to sort for main screen

One thing I'm thinking of adding as another field to the table VersionID, I.E 64 Bit, 32 Bit or both but not sure if I really need it anythoughts?

2020-04-20 (4).png


2020-04-20 (5).png
 
Thanks Crystal I did think is would work what I'll do is install my copy then see if the link manager works, I can aways uninstall it.
as long as the folder holding the datafile/images isn't moved there shouldn't be any problems.

You're welcome, Mick. In case its helpful, here is a function to get the path of your add-in folder (once it is actually running as an add-in -- otherwise it will get whatever folder you're developing in):

Rich (BB code):
Function GetCodeDbPath() As String
's4p'
   GetCodeDbPath = Left(CodeDb.Name, InStrRev(CodeDb.Name, "\"))
End Function

Sure, an alternative is to use a static path -- most people have a C: drive ... but it is kind of frowned upon to do it that way.
 
ps, Mick, if the linked database can get big, you would want to ocassionally unlink the table(s), compact it, then link the table(s) back again
 

Users who are viewing this thread

Back
Top Bottom