create CustomControl in code

  • Thread starter Thread starter Sergey Poberezovskiy
  • Start date Start date
S

Sergey Poberezovskiy

Hi,

How do I create a CustomControl in code?
using Application.CreateControl only creates a
placeholder, but how to associate it with an ActiveX
control?

Any help is greatly appreciated.
 
Arvin,

Thanks for your reply.

In Access Help constant acCustomControl is one of the
available to use in Application.CreateControl method; I
assume that there has to be a way to set newly created
control.

And up to the version 2003 Microsoft does set up these
controls in code - when re-creating database from Source
Safe - I do not know how though...

Any pointers, APIs, undocumented features would help.
 
You can...sort of Arvin!
The limitation is that you must have an existing OLE control that you
can copy its OLE data from.
http://support.microsoft.com/default.aspx?scid=KB;en-us;q147134

I've done this with my RotateText ActiveX control.
Dim Rotatelabel As Object

' This is a Template Report with only one Control: RotateLabel
DoCmd.OpenReport "RptRotText", acDesign

' New control in my Report
Set Rotatelabel = CreateReportControl(rpt.Name, acCustomControl,
acDetail, , , x, y)

' Get OLE Data from Template Object RotText
Rotatelabel.OleData = Reports!RptRotText!RotText.OleData
DoCmd.Restore

' Close Template Report
DoCmd.Close acReport, "RptRotText"



--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
I spent an hour looking, but couldn't find any. Stephen Lebans would
certainly be the one who'd know if there was a way. I see his post and still
am in the same boat that you are. I've looked through all the Hidden members
for a way, and found nothing. The only method I see is the same one that
Stephen points out in the KB article. That entails building a template form
and using the OLE information from the form. That doesn't make a whole lot
of sense to me unless I was continually creating and destroying instances,
something I almost never do. It appears to me that you could just as easily
show/hide an existing form.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Guys,
My problem is that I use Access through Automation, and
the only way I can get access to OLEData property is via
Application.Eval("Forms!Form1!Ctl1.OLEData")

Unfortunately it only returns a pointer, something like
"ᰕ6"
of String type back to the caller and not Byte() as it
does from within Access. I want to get that Byte() array
through Automation - any ideas?..
 
Hi Arvin,
there is no method I know of to programmatically instantiate an ActiveX
control onto an Access form. A few years ago I spent hours trying to
resolve this issue before I finally came across the KB article I ref'd
in my original post.

As to the OP's statement that since Source Safe(or SaveAsText) can
recreate an Access form containing ActiveX control, they are missing one
key point. The stored file does contain the OLE Data from the already
instantiated ActiveX control.

--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top