Page 2 of 2 FirstFirst 12
Results 16 to 30 of 30
  1. #16
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by moke123 View Post
    Did you export the modules as .cls files?I didn't see anyone else suggest this method but you may want to give it a try.I just tested it and it seems to work.
    1. Open the form module
    2. Delete anything that may be lingering such as "Option Compare Database" and "Option Explicit"
    3. Select Insert > File
    4. Navigate to your .cls file, select it, and click ok.

    There is some extra text at the top of the module you'll need to delete.Along the lines of:
    Code:
    VERSION 1.0 CLASSBEGIN  MultiUse = -1  'TrueEnd
    Good luck.
    There were no code modules left attached to the forms. The ENTIRE contents of the normal VBA window were gone. The only way to make the modules appear again was to open a form in design view and create an event on some control in the form. That made it appear in the VBA window again, but empty, except for the newly created event handler. However, as I wrote earlier, there is still some lingering trace of the code somewhere, because when I try to import the saved code, using the procedure you outline, I get error messages warning me of conflicting names.I've given it up at this point. I went back to my most recent backup and am redoing the work. The database was acting so weird that I don't think I'd trust it anyway, even if I did manage to get the code to appear again. I wouldn't mind seeing it appear - there were some things I did that will be a bit of work to re-invent, so being able to look at what I did would be helpful, even if I had to write it again.Can't be helped, though. No excuse - it was just stupidity on my part, that I didn't do backups of my work more often. So now I'm paying for it.
    Last edited by pdanes; 12-20-2020 at 07:22 AM.

  2. #17
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by moke123 View Post
    Did you export the modules as .cls files?

    I didn't see anyone else suggest this method but you may want to give it a try.
    I just tested it and it seems to work.


    1. Open the form module
    2. Delete anything that may be lingering such as "Option Compare Database" and "Option Explicit"
    3. Select Insert > File
    4. Navigate to your .cls file, select it, and click ok.


    There is some extra text at the top of the module you'll need to delete.
    Along the lines of:
    Code:
    VERSION 1.0 CLASS
    BEGIN
      MultiUse = -1  'True
    End
    Good luck.
    The ENTIRE contents of the VBA window are gone, despite all the forms still having their HasModule property set to Yes. The only way to get at the form's code is to open it in design view and make a new event routine for some control on the form. That makes it appear in the VBA window again, but empty, except for the newly created event routine. But as I wrote earlier, there are still some fragments of code lurking somewhere in the wreckage, because when I then try to import the previously exported code, using the procedure you outline, I get warnings about duplicate names.

    At this point, I've given up trying to restore it. The database is behaving so strangely that I wouldn't trust it anyway, even if I did manage to make the code reappear somehow. I wouldn't mind being able to look at the code, even if I couldn't use it. There are things that will be a bit of work to re-invent, and I don't remember exactly how I did them. But I did it once - I can do it again.

    No excuse - it was bonehead stupidity on my part to not keep a tight backup schedule, so now I'm paying for it.

  3. #18
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    I wish Access had that as a normal part of the C&R process.
    I created a shortcut using

    "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE" /decompile

    (change to suit your version of access)

    simple matter to click on in, then select the file you are working on

    if you are only working on one file, I guess you can add the path to it as well

  4. #19
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by Ajax View Post
    I created a shortcut using

    "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE" /decompile

    (change to suit your version of access)

    simple matter to click on in, then select the file you are working on

    if you are only working on one file, I guess you can add the path to it as well
    I do it slightly differently - I have either a batch or VBScript file (I use both at various times, according to what mood I'm in) that accepts a parameter, in the same folder in which I have the development version of the database. I can then simply drag the .ACCDB file onto that script file with the mouse, and it opens decompiled.

  5. #20
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    Quote Originally Posted by pdanes View Post
    The ENTIRE contents of the VBA window are gone, despite all the forms still having their HasModule property set to Yes.
    Just a thought (because I didn't see mentioned in this tread)...
    Have you ever tried something like this?
    Code:
    Sub PrintVBP()
        Dim i As Integer
    
        With VBE.ActiveVBProject.VBComponents
            For i = 1 To .Count
                With .Item(i)
                    Debug.Print .Name; ", Lines: " & .CodeModule.CountOfLines
                End With
            Next i
        End With
    End Sub
    Maybe you will find useful for the future (code backups etc) the properties and the methods of the CodeModule object.

  6. #21
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    Quote Originally Posted by accesstos View Post
    Just a thought (because I didn't see mentioned in this tread)...
    Have you ever tried something like this?
    Code:
    Sub PrintVBP()
        Dim i As Integer
    
        With VBE.ActiveVBProject.VBComponents
            For i = 1 To .Count
                With .Item(i)
                    Debug.Print .Name; ", Lines: " & .CodeModule.CountOfLines
                End With
            Next i
        End With
    End Sub
    Maybe you will find useful for the future (code backups etc) the properties and the methods of the CodeModule object.
    Chip Pearson has a great tutorial on vbe extensibility
    http://www.cpearson.com/excel/vbe.aspx
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  7. #22
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by accesstos View Post
    Just a thought (because I didn't see mentioned in this tread)...
    Have you ever tried something like this?
    Code:
    Sub PrintVBP()
        Dim i As Integer
    
        With VBE.ActiveVBProject.VBComponents
            For i = 1 To .Count
                With .Item(i)
                    Debug.Print .Name; ", Lines: " & .CodeModule.CountOfLines
                End With
            Next i
        End With
    End Sub
    Maybe you will find useful for the future (code backups etc) the properties and the methods of the CodeModule object.
    Thanks, just tried it. Nothing - VBE.ActiveVBProject.VBComponents.Count is 1 - this one module.

  8. #23
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by moke123 View Post
    Chip Pearson has a great tutorial on vbe extensibility
    http://www.cpearson.com/excel/vbe.aspx
    Yes, he does. I've benefitted from his articles many times over the years, and often still do.

  9. #24
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    I have a simple "developer" database that lists the current db's I'm working on, and current release version numbers etc.
    Double click the DB to open it, it takes a time stamped backup at that point then opens it.

    Although it won't stop you from not saving as you go, if you get in the habit of always opening it from there you get a pretty good backup trail.

    I also C & R and try and save then reopen as above very frequently.

    It doesn't stop issues though, I had a visually complicated report I was working on for most of a day that replicated a customers existing Word based quote form, it suddenly wouldn't open, Access "couldn't find it".
    Even the backup from the previous evening had the issue. I had to start again. The report itself only had about 10 lines of code. Very frustrating.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  10. #25
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by Minty View Post
    I have a simple "developer" database that lists the current db's I'm working on, and current release version numbers etc.
    Double click the DB to open it, it takes a time stamped backup at that point then opens it.

    Although it won't stop you from not saving as you go, if you get in the habit of always opening it from there you get a pretty good backup trail.

    I also C & R and try and save then reopen as above very frequently.

    It doesn't stop issues though, I had a visually complicated report I was working on for most of a day that replicated a customers existing Word based quote form, it suddenly wouldn't open, Access "couldn't find it".
    Even the backup from the previous evening had the issue. I had to start again. The report itself only had about 10 lines of code. Very frustrating.
    That sounds interesting. How does your developer DB know what you are working on? Do you populate it manually, or have it scan certain folders, or what?

  11. #26
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    Manual population of the database name and path, and then I have a standard local table in each DB with the current version number in it so I can query it.
    I record the last time I opened it as well just for posterity. I also maintain a version history log table that updates a similar table in each database.
    This is triggered by hitting the update version where it prompts me for the log data, sort of forces you to keep track.

    I used to also automate uploading the new versions to the central network location, when I was developing in house.
    That's a little more difficult when dealing with external clients.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  12. #27
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by Minty View Post
    Manual population of the database name and path, and then I have a standard local table in each DB with the current version number in it so I can query it.
    I record the last time I opened it as well just for posterity. I also maintain a version history log table that updates a similar table in each database.
    This is triggered by hitting the update version where it prompts me for the log data, sort of forces you to keep track.

    I used to also automate uploading the new versions to the central network location, when I was developing in house.
    That's a little more difficult when dealing with external clients.
    Sounds like a good idea. I should do something like that, that will automatically make backup copies for me when I'm too lazy to even click a button. Would have saved me a nice chunk of work right about now. I already have code in place to create backups, and I have code to recognize me, as opposed to the end user. It wouldn't be hard to combine those and even add some timing code, so it wouldn't make backups on every single restart, but maybe only if the last one was more than an hour ago, or some such. Yes, I think I'll do that, and now – before I rebuild all that lost work, so I don't lose it again. I know myself too well – I'll be careful for a while, then start slacking off again. Making it automatic will be safer.

    I also use versioning in stuff I do for customers, but I put it in a custom document property. A table would also work (obviously), but I started doing it this way and I have code already written to handle it, so I'm kind of used to it. This crashed one is single-user, single-file app. I just send that to the user via a file transfer portal when I have a new version for him. On start-up, it sucks in the latest data from his formerly current copy, then renames that copy according to an archival naming scheme and renames itself to the primary name, so all the user's shortcuts and last run pointers stay functional. The renaming is done via a VBScript file that it spawns and calls. The script file does the rename, re-starts the database and erases itself.

    My client-server apps also use a version number in a custom document property. The most current version is stored on the same server that contains the SQL Server database engine and all the actual data. The app on each user's machine looks at the copy of the app on the server and compares its version number against its own. When the one on the server is larger, the local app also spawns and calls a VBScript file, then shuts down. The script downloads the newer version of the Access app, with a different extension, then watches for the .laccdb file to vanish, indicating the database has finished closing. It then deletes the old version, renames the new version to the proper .accdb extension, re-starts the new version, and finally, deletes itself. To deploy a new version, all I have to do is give it a larger version number and copy it onto the server. Everything else is automatic from there.

    Both methods have served me well for years, each for a different sort of client. The script files that do the copy, rename and delete work take some fiddling with timing, otherwise I run into Windows' asynchronous file handling – a file that has been deleted and is theoretically gone may still conflict with a rename command. I don't know exactly what is going on, but I have run into this many times, so I have Sleep commands built in, so that even AFTER the script detects that it is 'okay' and the action should be able to proceed, I still have it sleep for a while. That 'while' sometimes needs to be adjusted, as newer OS releases will occasionally break something. It's odd, though – identical OS versions on identical machines work on some machines and crash on others. But it's always just a matter of putting in an adequate delay – long enough to be safe, but not so long as to unnecessarily irritate the users.

  13. #28
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    I used to have an automatic FE script / VBS or bat file in house, and I had similar issues with renaming old versions, new versions not copying completely before trying to open etc etc.
    I did eventually find some clever script that checked if the file could be not be opened somehow, and looped until it could then finished things off.

    It's funny how looking at something fresh make you think about it - have just reordered my project list by most recently opened date at the top, no idea why I didn't do that before... Busman's holiday
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  14. #29
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by Minty View Post
    I used to have an automatic FE script / VBS or bat file in house, and I had similar issues with renaming old versions, new versions not copying completely before trying to open etc etc.
    I did eventually find some clever script that checked if the file could be not be opened somehow, and looped until it could then finished things off.

    It's funny how looking at something fresh make you think about it - have just reordered my project list by most recently opened date at the top, no idea why I didn't do that before... Busman's holiday
    Got it - about ten minutes to set it up, and it works great. Created a custom document variable to hold the date and time to nearest minute, as a text string, because the date format of custom document variables does not allow a time component. The following runs in the primary form's Open event:

    Code:
    Set fs = CreateObject("Scripting.FileSystemObject")
    If gbl_Uzivatel Like "*danes*" Then
        If Format$(DateAdd("h", -1, Now), "YYYY-MM-DD HH:NN") > ReadCustomDocumentProperty("PosledniDevZaloha") Then
            fs.CopyFile CurrentProject.Path & "\DataSavcu.accdb", CurrentProject.Path & "\DevZalohy\DataSavcuDevZaloha_" & Format$(Now(), "yyyy-mm-dd_hh-nn-ss") & ".accdb"
            WriteCustomDocumentProperty "PosledniDevZaloha", Format$(Now, "YYYY-MM-DD HH:NN")
        End If
    End If
    Created a special subfolder alongside the database and all development backups go in there. The code first checks to see if I am running it (so it won't do anything on the end user's machine). If it's me, it then looks to see if the last backup was more than an hour ago. If also yes, it makes a date/time stamped backup and updates the date/time of last backup in the custom document variable. For how much effort this took, and how much work it would have saved me, I'll have to buy myself a new pair of steel-toed boots to kick myself in the ass for not doing it long ago. This is going in everything I build from now on. Many thanks for the steer. If you ever make a trip to Prague, the beer is on me.

  15. #30
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    Quote Originally Posted by pdanes View Post
    Got it - about ten minutes to set it up, and it works great. Created a custom document variable to hold the date and time to nearest minute, as a text string, because the date format of custom document variables does not allow a time component. The following runs in the primary form's Open event:

    Code:
    Set fs = CreateObject("Scripting.FileSystemObject")
    If gbl_Uzivatel Like "*danes*" Then
        If Format$(DateAdd("h", -1, Now), "YYYY-MM-DD HH:NN") > ReadCustomDocumentProperty("PosledniDevZaloha") Then
            fs.CopyFile CurrentProject.Path & "\DataSavcu.accdb", CurrentProject.Path & "\DevZalohy\DataSavcuDevZaloha_" & Format$(Now(), "yyyy-mm-dd_hh-nn-ss") & ".accdb"
            WriteCustomDocumentProperty "PosledniDevZaloha", Format$(Now, "YYYY-MM-DD HH:NN")
        End If
    End If
    Created a special subfolder alongside the database and all development backups go in there. The code first checks to see if I am running it (so it won't do anything on the end user's machine). If it's me, it then looks to see if the last backup was more than an hour ago. If also yes, it makes a date/time stamped backup and updates the date/time of last backup in the custom document variable. For how much effort this took, and how much work it would have saved me, I'll have to buy myself a new pair of steel-toed boots to kick myself in the ass for not doing it long ago. This is going in everything I build from now on. Many thanks for the steer. If you ever make a trip to Prague, the beer is on me.
    Excellent - Prague is on the list once the 'Rona is under control, so I might take you up on that.
    One other thing - I added a second drive and put the back ups in there, just in case of drive failure. For what they cost it seemed a no brainer, and removed the local single point of failure.
    We also subscribe to an online cloud back up which allows us to store about 100Gb for about $160 a year, so proper belt and braces. That runs at midnight and is clever enough to only make copies of new or only changed files.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. VBA code to import text Files
    By moorecurls in forum Programming
    Replies: 4
    Last Post: 02-21-2020, 02:58 PM
  2. Replies: 3
    Last Post: 02-13-2019, 10:22 PM
  3. VBA to Import CSV - Code problem with CR/LF vs LF only
    By jhrBanker in forum Import/Export Data
    Replies: 8
    Last Post: 09-11-2014, 01:32 PM
  4. Import Module Code Bug Problem
    By Ace2014 in forum Modules
    Replies: 17
    Last Post: 06-26-2014, 03:00 AM
  5. VBA Import Code Problem
    By jhrBanker in forum Import/Export Data
    Replies: 21
    Last Post: 05-16-2014, 10:15 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums