Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2005
    Posts
    4

    Unanswered: MakeCompiledFile

    Hi,
    I would like to compile the access db runtime. Does anybody know how to compile dynamically the access DB?

    I have MS Access 2002 and VBA 6.4.99.69. I have tried :
    VBIDE.VBProject vbp = oAccess.VBE.ActiveVBProject;
    vbp.Collection.Item(1).MakeCompiledFile();

    I've tested the Item(1), all was OK, BuildFileName etc. but I get error in execution, Access said something like "Cannot complete command".

    The sae result I had when tried:
    oAccess.DoCmd.SelectObject(Access.AcObjectType.acM odule, "Module", false);
    oAccess.VBE.ActiveVBProject.MakeCompiledFile();

    or

    oAccess.DoCmd.RunCommand(Access.AcCommand.acCmdCom pileAllModules);

    Thank you in advance.

  2. #2
    Join Date
    Mar 2005
    Posts
    261
    I assume the code does actually compile manually without errors? If so, both of these methods should work;

    DoCmd.RunCommand(acCmdCompileAllModules)

    SysCmd 504, 16483

    The second is an undocumented way of doing it (which means M$ don't support this method).

    Note: If the code contains errors, these methods will not warn you - they will simply fail to compile.

    HTH

    Wayne Phillips
    http://www.everythingaccess.com

  3. #3
    Join Date
    Nov 2005
    Posts
    4
    The error is "Cannot compile project" and I have such error when I've made a macro with RunCommand "CompileAllModules" and tried to run it in Access. But when I open VB and choose Debug:Compile all is OK

    Any ideas? maybe something wrong in VB?

  4. #4
    Join Date
    Nov 2005
    Posts
    4

    more details

    I have Access object as process by:
    oAccess = (Access.Application) Marshal.BindToMoniker(sDBPath);

    not

    oAccess.OpenCurrentDatabase(sDBPath, true, "");

    All bugs disappeared when I've got Access db by second method. But I'm still curious about the errors when using the first.

  5. #5
    Join Date
    Mar 2005
    Posts
    261
    Also interesting: DoCmd.RunCommand(acCmdCompileAllModules) does not display any errors, even if it fails to compile the code. However, in the macro form it does. Strange.

    Ok, so BindToMoniker is the .Net equivelent of GetObject() in VB6/VBA, so I tried to replicate your problem by creating a macro then testing this:

    Code:
    Set objAccess = GetObject(strDbPath)
        objAccess.DoCmd.RunMacro "McrCompileCode"
    Which worked fine. Not sure why it wouldn't work in .Net

  6. #6
    Join Date
    Nov 2005
    Posts
    4

    nevermind

    I've missed to tell that the db was 97, I have converted it to 2002 manually and then I've made my experiments.

    By the second way (oAccess.OpenCurrentDatabase(sDBPath, true, "") I'm using 97 db without any problems.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •