Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Okay, Micron, that is just brilliant
    Coming from anyone in your league, that is a supreme compliment.
    Thanks.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  2. #17
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,399
    Credit where credit’s due

  3. #18
    twgonder is offline Expert
    Windows 10 Access 2016
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    653

    Now the same code for forms won't compile

    I was doing fine, got the background colors to change in reports as I wanted based on post #6
    Then I started adding code to do the same thing in a module for forms.
    But the dang thing won't compile, and stops with this error message below (highlight where the compiler shows the error).

    I've tried changing the name of the x.db in the Dim, just in case there was a conflict between the two modules (I wouldn't expect that).
    I can't figure out why it will compile for the report module but not the form module.
    Both do almost exactly the same thing, they just modify different properties based on being a form or report.
    I have decompiled the db in case that might be it, nope.

    Am I missing something in the code ( I am new to VBA)?
    Click image for larger version. 

Name:	220809CompileErr1.jpg 
Views:	15 
Size:	201.3 KB 
ID:	48483
    Last edited by twgonder; 08-09-2022 at 05:12 AM. Reason: new image

  4. #19
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    I am surprised that the "d" in DAO.database is in lower case.
    Typically when entering vba code, intellisense will be invoked and that "d" will be capitalized "D".

    Something doesn't look right. But the DAO.Recordset below that seems correct?
    Perhaps someone else has an explanation.

  5. #20
    twgonder is offline Expert
    Windows 10 Access 2016
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    653
    I just tried a report, and now that code that used to work fine, failed with the same compile error.
    So it might be something elsewhere that's causing a problem, but I'm not sure how to find it.

    I rebooted after several Access crashes, that didn't help

    Is there something in the access options that could stop the DAO part from working?

    New:
    I had imported these modules, and everything else to create a new db on advice of some of the crashes in Access I was having.
    I went back to the old version of db and it complies, but it's the same code.
    Is there a problem with importing modules?
    I'll do those two modules again and see what happens.

    NewNew:
    I was doubting some code because of having problems with crashes in Access (it stops abruptly, does a backup, maybe a repair and starts again).
    So, I didn't import some modules that I had gotten for doing foreign language translations
    Could anything in other modules affect the Dim that's failing here, or rather make it work? It's a pretty simple statement?
    Last edited by twgonder; 08-09-2022 at 07:41 AM.

  6. #21
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    This is Access 2016 as your info shows? Older versions required a reference to DAO but 2016 should not.

    I've never multi dim'd on one line like that, so what I'd do is separate them and try compiling. If that fails I'd rem out the database line and try again with only the recordset line. If it compiles it's not a reference issue IMO - it's corruption (presuming this is 2016 db). After that I might copy the module code (not the module) to a new db and see what happens, assuming there are no references to other things that are not in this new db. You could always rem those out as the only important lines are the DAO lines.

    If that works, I might copy/save the code text, remove the procedure from the problem db, save/close/reopen, decompile/compile per proper procedure, paste the code back in and compile again.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #22
    twgonder is offline Expert
    Windows 10 Access 2016
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    653
    Quote Originally Posted by Micron View Post
    This is Access 2016 as your info shows? Older versions required a reference to DAO but 2016 should not...
    I just finally gave up. I had a version before with identical code, multi-dim and no problems. So I'll just keep importing bits over until it fails.

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

Similar Threads

  1. Replies: 7
    Last Post: 11-06-2017, 02:45 AM
  2. Replies: 29
    Last Post: 05-02-2017, 04:38 PM
  3. Replies: 2
    Last Post: 03-06-2013, 11:37 PM
  4. Relating similar fields???
    By smoothlarryhughes in forum Access
    Replies: 10
    Last Post: 02-26-2013, 12:50 PM
  5. Replies: 5
    Last Post: 08-29-2011, 05:17 PM

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