UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
2 Pages V  1 2 >  (Go to first unread post)
   Reply to this topicStart new topic
> Create Accde From Within The Accdb - Vba, Access 2016    
 
   
Louverril
post Jan 6 2020, 11:31 AM
Post#1



Posts: 516
Joined: 29-April 08



Hello and a Happy New Year to all!

I am using
CODE
.SysCmd 603, strACCDBToCompile, strAccdePathandName
to create an accde version.

This works fine if strACCDBToCompile is an external accdb - is there any way to automate the creation of an accde from within the current accdb? in other words without having to copy it first?

Many thanks.

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
GroverParkGeorge
post Jan 6 2020, 11:39 AM
Post#2


UA Admin
Posts: 36,747
Joined: 20-June 02
From: Newcastle, WA


Interesting. I'm not sure I've seen that done.

Can you post the COMPLETE procedure, though.

I'm wondering why you chose to use the literal 603 ?

I don't see it on the list of enumerations?
This post has been edited by GroverParkGeorge: Jan 6 2020, 11:44 AM

--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
theDBguy
post Jan 6 2020, 11:46 AM
Post#3


UA Moderator
Posts: 77,481
Joined: 19-June 07
From: SunnySandyEggo


Hi. I find it very curious as well. I may have not done it correctly, but I just tried your code, and it didn't do anything for me. Nothing happened. No errors either.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
JeffK
post Jan 6 2020, 02:19 PM
Post#4


UtterAccess VIP
Posts: 1,585
Joined: 19-December 02
From: Lansing, MI


I've never been able to have a function create an mde/accde out of the currently open database without copying the file first.

For unopened files, the following is what I use. Note that it's important to perform the SysCmd call on an instance of Access with no database open. There are a few undocumented SysCmd options that do useful things...

CODE
Public Function alMakeMDE(strDatabaseIN As String, strDatabaseOUT As String) As Boolean

Dim app As Access.Application

Set app = New Access.Application
app.SysCmd 603, strDatabaseIN, strDatabaseOUT

app.Quit
Set app = Nothing

End Function


Go to the top of the page
 
theDBguy
post Jan 6 2020, 02:31 PM
Post#5


UA Moderator
Posts: 77,481
Joined: 19-June 07
From: SunnySandyEggo


Hi JeffK. Thanks for the clarification. Got any reference to learn more about the other useful gems?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
JeffK
post Jan 6 2020, 02:45 PM
Post#6


UtterAccess VIP
Posts: 1,585
Joined: 19-December 02
From: Lansing, MI


I don't have an organized resource handy. They're just littered throughout my code library...

712 springs to mind because I had to modify a function with it recently. Comes in handy for saving the contents of an image control to a file:

CODE
Public Sub SavePictureFile(img As Image, strFileName As String)

Dim pic As stdole.IPictureDisp

Set pic = SysCmd(712, img)
    
SavePicture pic, strFileName

Set pic = Nothing

End Sub
Go to the top of the page
 
theDBguy
post Jan 6 2020, 02:54 PM
Post#7


UA Moderator
Posts: 77,481
Joined: 19-June 07
From: SunnySandyEggo


Hmm, img As Image, what would that be referring to? How do you pass it to the function? Just curious... Thanks.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
JeffK
post Jan 6 2020, 03:04 PM
Post#8


UtterAccess VIP
Posts: 1,585
Joined: 19-December 02
From: Lansing, MI


Pass a reference to the control when calling the function. Pass the control object itself, not its name as a string.

SaveImageFile Me.ImageControlName, "FileName"

That will save the current contents of the image control to FileName.

My team has a few analysis apps that write directly to an image control's PictureData property to draw on an Access form. This function allows users to save the results as an external image file for use elsewhere.
Go to the top of the page
 
theDBguy
post Jan 6 2020, 03:11 PM
Post#9


UA Moderator
Posts: 77,481
Joined: 19-June 07
From: SunnySandyEggo


Okay, makes sense. Thanks again. And please, let us know if you remember other hidden treasures. Cheers!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
Louverril
post Jan 7 2020, 10:45 AM
Post#10



Posts: 516
Joined: 29-April 08



Hi and thanks for the reply theDBGuy - yes that's exactly what happens with me if I use the current db as strACCDBToCompile -nothing! :-)

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
theDBguy
post Jan 7 2020, 10:56 AM
Post#11


UA Moderator
Posts: 77,481
Joined: 19-June 07
From: SunnySandyEggo


QUOTE (Louverril)
Hi and thanks for the reply theDBGuy - yes that's exactly what happens with me if I use the current db as strACCDBToCompile -nothing! :-)

Hi. But I was talking about using an external db to compile. The only difference was I didn't use a new instance of Access, like Jeff said. In other words, if strACCDBToCompile was pointing to an external file, this code I used, didn't do anything.
CODE
SysCmd 603, strACCDBToCompile, strAccdePathandName

Notice it didn't have a dot at the beginning of the code, like in how you originally posted it. What was missing in your original post, and that's why I didn't understand it, was what that dot was referring to. I assumed it was referring to Application, as in: Application.SysCmd

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
Louverril
post Jan 7 2020, 10:59 AM
Post#12



Posts: 516
Joined: 29-April 08



Hi and thanks for reply - there are several reference to syscmd 603 on the web, but it is apparently undocumented by Microsoft (not mentioned here: https://docs.microsoft.com/en-us/office/vba...cation.syscmd)?. This is my exact code which works fine if you copy the current db first to become the strACCDBToCompile.

CODE
Public Function createACCDE(strAccdePathandName As String, strACCDBToCompile As String) As Boolean
    Dim objOtherAccess  As New Access.Application
    Dim lngHwnd As Long

    On Error GoTo ITAError
    
    Set objOtherAccess = New Access.Application
    
    With objOtherAccess
        .visible = True 'True if need to enter an encrypted db passw0rd 'False - Otherwise a login screen might pop up
        .AutomationSecurity = 1 'msoAutomationSecurityLow
        SetForegroundWindow objOtherAccess.hWndAccessApp
        .SysCmd 603, strACCDBToCompile, strAccdePathandName
      
    End With
    
     objOtherAccess.Quit
    Set objOtherAccess = Nothing
  
     'Success
    createACCDE = True

ITAExit:

     Exit Function

ITAError:

    ITATrapErrors Err.Number, Err.Description, "createACCDE"
    'MsgBox Err.Number & " " & Err.Description
    'Resume Next
    Resume ITAExit

End Function




--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
Louverril
post Jan 7 2020, 11:01 AM
Post#13



Posts: 516
Joined: 29-April 08



Sorry theDBGuy - hopefully my last post clarified it.

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
theDBguy
post Jan 7 2020, 11:11 AM
Post#14


UA Moderator
Posts: 77,481
Joined: 19-June 07
From: SunnySandyEggo


QUOTE (Louverril)
Sorry theDBGuy - hopefully my last post clarified it.

Hi Allyson. Yes, thank you. That clarifies the missing piece, which was objOtherAccess. Unfortunately, as Jeff said, I guess what you want to do is not possible, unless someone else has any more ideas. Good luck!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
GroverParkGeorge
post Jan 7 2020, 11:16 AM
Post#15


UA Admin
Posts: 36,747
Joined: 20-June 02
From: Newcastle, WA


Yes, I agree. I have never seen anything suggesting you can create an mde/accde from the open mdb/accdb via VBA. It think you can only do it by using the interface.

Attached File  makeaccde.png ( 42.8K )Number of downloads: 1

--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
Louverril
post Jan 7 2020, 11:21 AM
Post#16



Posts: 516
Joined: 29-April 08



Hi the the DBGuy,

Thanks - it looking like it :-(

Tried this - in hope rather than expectation - after you highlight the reference to the dot - thank you. But still did nothing (no error either).

CODE
   Set objOtherAccess = Access.Application
    objOtherAccess.SysCmd 603, CurrentDb.Name, strAccdePathandName



I wondered if I was setting the objOtherAccess the right way to refer to the current application.

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
Louverril
post Jan 7 2020, 11:22 AM
Post#17



Posts: 516
Joined: 29-April 08



Thanks GroverParkGeorge,

Would the only way to automate this be with sendkeys?

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
Louverril
post Jan 7 2020, 11:27 AM
Post#18



Posts: 516
Joined: 29-April 08



PS this does nothing either:

Application.SysCmd 603, CurrentDb.Name, strAccdePathandName

--------------------
Cheers!

Allyson
UK North Yorkshire / North East
Go to the top of the page
 
theDBguy
post Jan 7 2020, 11:31 AM
Post#19


UA Moderator
Posts: 77,481
Joined: 19-June 07
From: SunnySandyEggo


QUOTE (Louverril)
PS this does nothing either:

Application.SysCmd 603, CurrentDb.Name, strAccdePathandName

Unfortunately, that was the first thing I tried earlier (even before I tried using an external file).

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
GroverParkGeorge
post Jan 7 2020, 11:31 AM
Post#20


UA Admin
Posts: 36,747
Joined: 20-June 02
From: Newcastle, WA


I avoid doing ANYTHING with SendKeys. Except for extreme necessity, and only after a few stiff drinks to fortify my resolve.

In other words, it may be possible, but do so at your own risk.

--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
2 Pages V  1 2 >


Custom Search


RSSSearch   Top   Lo-Fi    16th February 2020 - 11:05 PM