Making QRCode ActiveX Control for MS Access: Control Source Property
I wanted to implement a QR Code to Access2010 and I found https://github.com/yas78/QRCodeLibVBA. Referencing XLAM from Access did not work and I didn't want to insert all modules directly to Access as it makes the project messy.
So I decided to create an OCX file using ancient VB6 as it seemed to be the easiest way to encapsulate all the bits together into one simple object.
Finally, I have made an OCX that has several key properties: DataString
which is the string to be displayed, ByteModeCharsetName
, ErrorCorrectionLevel
, ForeRGB
and BackRGB
, there are also methods Refresh
, Cls
and events OnClick
and OnDblClick
It works fine in VB6 apps + Excel sheets + Excel forms but it behaves weird in Access forms, reports, etc.
Everything looks as one would expect in Excel:
This is how it looks in Access:
- The custom properties are visible on the tab "Other" but they are not offered in VBA editor at all! However it does compile when entered manually.
- Resizing control behaves weird
- Control's Events like
OnClick
are not displayed at tab Event of Property Sheet
Here are my questions:
- Are the Controls for Access "different" than for other office apps?
- Why the hell are the properties hidden in editor?
- How to "move" some properties to other tabs (categories), for example
ForeRGB
to tab Format (as usual for TextBoxes etc.)? - How to create
ControlSource
propety (on the DATA tab) which could be directly bound to a recordset without having to use a VBA? This way, I hope, I could use the control on the continuous forms as well. In fact, this is most important question. - Some tips for resizing? (not important)
I think I'm pretty close to my goal but I'm stuck at this point. I know the VB6 is obsolete but after reading Creating Custom Controls for ms access 2010 VB6 seems to be easy choice. Any alternatives for writing OCX?
EDIT: Final working control is available here https://github.com/Combinatix/QRCodeAX
vba ms-access vb6 activex qr-code
add a comment |
I wanted to implement a QR Code to Access2010 and I found https://github.com/yas78/QRCodeLibVBA. Referencing XLAM from Access did not work and I didn't want to insert all modules directly to Access as it makes the project messy.
So I decided to create an OCX file using ancient VB6 as it seemed to be the easiest way to encapsulate all the bits together into one simple object.
Finally, I have made an OCX that has several key properties: DataString
which is the string to be displayed, ByteModeCharsetName
, ErrorCorrectionLevel
, ForeRGB
and BackRGB
, there are also methods Refresh
, Cls
and events OnClick
and OnDblClick
It works fine in VB6 apps + Excel sheets + Excel forms but it behaves weird in Access forms, reports, etc.
Everything looks as one would expect in Excel:
This is how it looks in Access:
- The custom properties are visible on the tab "Other" but they are not offered in VBA editor at all! However it does compile when entered manually.
- Resizing control behaves weird
- Control's Events like
OnClick
are not displayed at tab Event of Property Sheet
Here are my questions:
- Are the Controls for Access "different" than for other office apps?
- Why the hell are the properties hidden in editor?
- How to "move" some properties to other tabs (categories), for example
ForeRGB
to tab Format (as usual for TextBoxes etc.)? - How to create
ControlSource
propety (on the DATA tab) which could be directly bound to a recordset without having to use a VBA? This way, I hope, I could use the control on the continuous forms as well. In fact, this is most important question. - Some tips for resizing? (not important)
I think I'm pretty close to my goal but I'm stuck at this point. I know the VB6 is obsolete but after reading Creating Custom Controls for ms access 2010 VB6 seems to be easy choice. Any alternatives for writing OCX?
EDIT: Final working control is available here https://github.com/Combinatix/QRCodeAX
vba ms-access vb6 activex qr-code
If interested, here is an alternative
– krish KM
Nov 12 '18 at 13:33
add a comment |
I wanted to implement a QR Code to Access2010 and I found https://github.com/yas78/QRCodeLibVBA. Referencing XLAM from Access did not work and I didn't want to insert all modules directly to Access as it makes the project messy.
So I decided to create an OCX file using ancient VB6 as it seemed to be the easiest way to encapsulate all the bits together into one simple object.
Finally, I have made an OCX that has several key properties: DataString
which is the string to be displayed, ByteModeCharsetName
, ErrorCorrectionLevel
, ForeRGB
and BackRGB
, there are also methods Refresh
, Cls
and events OnClick
and OnDblClick
It works fine in VB6 apps + Excel sheets + Excel forms but it behaves weird in Access forms, reports, etc.
Everything looks as one would expect in Excel:
This is how it looks in Access:
- The custom properties are visible on the tab "Other" but they are not offered in VBA editor at all! However it does compile when entered manually.
- Resizing control behaves weird
- Control's Events like
OnClick
are not displayed at tab Event of Property Sheet
Here are my questions:
- Are the Controls for Access "different" than for other office apps?
- Why the hell are the properties hidden in editor?
- How to "move" some properties to other tabs (categories), for example
ForeRGB
to tab Format (as usual for TextBoxes etc.)? - How to create
ControlSource
propety (on the DATA tab) which could be directly bound to a recordset without having to use a VBA? This way, I hope, I could use the control on the continuous forms as well. In fact, this is most important question. - Some tips for resizing? (not important)
I think I'm pretty close to my goal but I'm stuck at this point. I know the VB6 is obsolete but after reading Creating Custom Controls for ms access 2010 VB6 seems to be easy choice. Any alternatives for writing OCX?
EDIT: Final working control is available here https://github.com/Combinatix/QRCodeAX
vba ms-access vb6 activex qr-code
I wanted to implement a QR Code to Access2010 and I found https://github.com/yas78/QRCodeLibVBA. Referencing XLAM from Access did not work and I didn't want to insert all modules directly to Access as it makes the project messy.
So I decided to create an OCX file using ancient VB6 as it seemed to be the easiest way to encapsulate all the bits together into one simple object.
Finally, I have made an OCX that has several key properties: DataString
which is the string to be displayed, ByteModeCharsetName
, ErrorCorrectionLevel
, ForeRGB
and BackRGB
, there are also methods Refresh
, Cls
and events OnClick
and OnDblClick
It works fine in VB6 apps + Excel sheets + Excel forms but it behaves weird in Access forms, reports, etc.
Everything looks as one would expect in Excel:
This is how it looks in Access:
- The custom properties are visible on the tab "Other" but they are not offered in VBA editor at all! However it does compile when entered manually.
- Resizing control behaves weird
- Control's Events like
OnClick
are not displayed at tab Event of Property Sheet
Here are my questions:
- Are the Controls for Access "different" than for other office apps?
- Why the hell are the properties hidden in editor?
- How to "move" some properties to other tabs (categories), for example
ForeRGB
to tab Format (as usual for TextBoxes etc.)? - How to create
ControlSource
propety (on the DATA tab) which could be directly bound to a recordset without having to use a VBA? This way, I hope, I could use the control on the continuous forms as well. In fact, this is most important question. - Some tips for resizing? (not important)
I think I'm pretty close to my goal but I'm stuck at this point. I know the VB6 is obsolete but after reading Creating Custom Controls for ms access 2010 VB6 seems to be easy choice. Any alternatives for writing OCX?
EDIT: Final working control is available here https://github.com/Combinatix/QRCodeAX
vba ms-access vb6 activex qr-code
vba ms-access vb6 activex qr-code
edited Nov 14 '18 at 19:50
Combinatix
asked Nov 10 '18 at 23:58
CombinatixCombinatix
5031717
5031717
If interested, here is an alternative
– krish KM
Nov 12 '18 at 13:33
add a comment |
If interested, here is an alternative
– krish KM
Nov 12 '18 at 13:33
If interested, here is an alternative
– krish KM
Nov 12 '18 at 13:33
If interested, here is an alternative
– krish KM
Nov 12 '18 at 13:33
add a comment |
3 Answers
3
active
oldest
votes
For 4. try setting your control's DataBindingBehavior
to vbSimpleBound
so that a scalar property (ControlSource
in your case) can be bound via DataSource
and DataMember
properties.
For 3. use Tools->Procedure Attributes...
menu, select ControlSource
in Name, expand Advanced>>
and select Data in Property Category
combobox. You can do the same through Object Browser (F2). Find your control, right click your property/method (should be bold) and choose Properties...
context menu option. This works with methods and is more versatile than Tools->Procedure Attributes...
approach.
I have briefly tested your advices and binded myDataString
to theControl Source
. It wors great! But the bastard Access now refuses to display the form as Continuous: A form with a bound ActiveX control or an embedded object bound to a data source can't have its DefaultView property set to Continuous Forms. I have a bad feeling about this... Any sugestions?
– Combinatix
Nov 11 '18 at 13:07
1
@Combinatrix As shared in my answer, generally, it's hard to impossible to make an ActiveX control display something else for every row. Bound ActiveX controls aren't available on continuous subforms. However, you can try using theDetail_Paint
event to display something specific to the record being painted, but anything you do inDetail_Paint
that triggers a repaint causes an infinite loop (and things that change how objects are displayed often trigger a repaint of the entire form).
– Erik von Asmuth
Nov 11 '18 at 15:05
add a comment |
To answer your questions one by one:
Yes. ActiveX controls in Access are certainly different than in other Office applications.
In Access, there's one general CustomControl control that encapsulates all ActiveX controls, and offers a default set of events, properties and methods for any control, such as border properties, the requery method, and the enter event.
The object of the control being encapsulated can be accessed by using the
CustomControl.Object
proprtyThese properties aren't displayed because you're referring to a custom control in the general sense, and only get the properties for it.
To get the object you want, use the following:
Dim qrObj As QRCode
Set qrObj = QR.ObjectThat's plain not possible, tab layout is determined by Access
Also not possible. The ActiveX control must include that functionality, this one doesn't. Generally, using ActiveX controls in continuous subforms to display something different for every row is hard to impossible
Resizing the outer control, and then calling
CustomControl.SizeToFit
should generally just work
Some of the things I deem not possible can be achieved by modifying the ActiveX Control's source code, of course.
Rrright... Are you saying that Access'sCustomControl
wrapper have to understand my OCX's props and then it can propagate them to the right property tabs? I have the source code and I can do what I want with it (almost)
– Combinatix
Nov 11 '18 at 11:54
Yup, wqw just shared an answer on that
– Erik von Asmuth
Nov 11 '18 at 12:30
add a comment |
A very different and much less cumbersome approach would be to generate the QR code online and download them to be displayed in a (bound) picture control.
I wrote an article on displaying online images:
Show pictures directly from URLs in Access forms and reports
Some code is, of course, needed, but much less than that at GiHub you refer to, though to much to list here in full.
It uses this function retrieve the images:
' Download (picture) file from a URL of a hyperlink field to a
' (temporary) folder, and return the full path to the downloaded file.
'
' This can be used as the control source for a bound picture control.
' If no Folder is specified, the user's IE cache folder is used.
'
' Typical usage in the RecordSource for a form or report where Id is
' the unique ID and Url is the hyperlink field holding the URL to
' the picture file to be displayed:
'
' - to a cached file where parameter Id is not used:
'
' Select *, UrlContent(0, [Url]) As Path From SomeTable;
'
' - or, where Id is used to create the local file name:
'
' Select *, UrlContent([Id], [Url], "d:somefolder") As Path From SomeTable;
'
' Then, set ControlSource of the bound picture control to: Path
'
' 2017-05-28. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function UrlContent( _
ByVal Id As Long, _
ByVal Url As String, _
Optional ByVal Folder As String) _
As Variant
Const NoError As Long = 0
Const Dot As String = "."
Const BackSlash As String = ""
Dim Address As String
Dim Ext As String
Dim Path As String
Dim Result As String
' Strip leading and trailing octothorpes from URL string.
Address = HyperlinkPart(Url, acAddress)
' If Address is a zero-length string, Url was not wrapped in octothorpes.
If Address = "" Then
' Use Url as is.
Address = Url
End If
If Folder = "" Then
' Import to IE cache.
Result = DownloadCacheFile(Address)
Else
If Right(Folder, 1) <> BackSlash Then
' Append a backslash.
Folder = Folder & BackSlash
End If
' Retrieve extension of file name.
Ext = StrReverse(Split(StrReverse(Address), Dot)(0))
' Build full path for downloaded file.
Path = Folder & CStr(Id) & Dot & Ext
If DownloadFile(Address, Path) = NoError Then
Result = Path
End If
End If
UrlContent = Result
End Function
I pasted this URL into a record:
https://chart.googleapis.com/chart?cht=qr&chs=300x300&chl=23457
and it worked right away:
Full code can be found at GitHub: VBA.PictureUrl
I have used your Scenario 1 - Download and Display in the past. However this does not really answer my questions. My current OCX works almost perfect and after placing it to new access database it requires only one line of VBAQR.DataString = Me!SomeField
. Also, the database stays internet-independend. The goal of my question was to find out how to insert Access-specific features into an OCX.
– Combinatix
Nov 11 '18 at 11:07
1
I've only worked with third-party OCX and don't have VB6, so I have no clue, sorry. Just wanted to make sure, you were aware of an alternative. Also, the use of OCX has decreased as they usually don't work with 64-bit Access.
– Gustav
Nov 11 '18 at 11:27
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244605%2fmaking-qrcode-activex-control-for-ms-access-control-source-property%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
For 4. try setting your control's DataBindingBehavior
to vbSimpleBound
so that a scalar property (ControlSource
in your case) can be bound via DataSource
and DataMember
properties.
For 3. use Tools->Procedure Attributes...
menu, select ControlSource
in Name, expand Advanced>>
and select Data in Property Category
combobox. You can do the same through Object Browser (F2). Find your control, right click your property/method (should be bold) and choose Properties...
context menu option. This works with methods and is more versatile than Tools->Procedure Attributes...
approach.
I have briefly tested your advices and binded myDataString
to theControl Source
. It wors great! But the bastard Access now refuses to display the form as Continuous: A form with a bound ActiveX control or an embedded object bound to a data source can't have its DefaultView property set to Continuous Forms. I have a bad feeling about this... Any sugestions?
– Combinatix
Nov 11 '18 at 13:07
1
@Combinatrix As shared in my answer, generally, it's hard to impossible to make an ActiveX control display something else for every row. Bound ActiveX controls aren't available on continuous subforms. However, you can try using theDetail_Paint
event to display something specific to the record being painted, but anything you do inDetail_Paint
that triggers a repaint causes an infinite loop (and things that change how objects are displayed often trigger a repaint of the entire form).
– Erik von Asmuth
Nov 11 '18 at 15:05
add a comment |
For 4. try setting your control's DataBindingBehavior
to vbSimpleBound
so that a scalar property (ControlSource
in your case) can be bound via DataSource
and DataMember
properties.
For 3. use Tools->Procedure Attributes...
menu, select ControlSource
in Name, expand Advanced>>
and select Data in Property Category
combobox. You can do the same through Object Browser (F2). Find your control, right click your property/method (should be bold) and choose Properties...
context menu option. This works with methods and is more versatile than Tools->Procedure Attributes...
approach.
I have briefly tested your advices and binded myDataString
to theControl Source
. It wors great! But the bastard Access now refuses to display the form as Continuous: A form with a bound ActiveX control or an embedded object bound to a data source can't have its DefaultView property set to Continuous Forms. I have a bad feeling about this... Any sugestions?
– Combinatix
Nov 11 '18 at 13:07
1
@Combinatrix As shared in my answer, generally, it's hard to impossible to make an ActiveX control display something else for every row. Bound ActiveX controls aren't available on continuous subforms. However, you can try using theDetail_Paint
event to display something specific to the record being painted, but anything you do inDetail_Paint
that triggers a repaint causes an infinite loop (and things that change how objects are displayed often trigger a repaint of the entire form).
– Erik von Asmuth
Nov 11 '18 at 15:05
add a comment |
For 4. try setting your control's DataBindingBehavior
to vbSimpleBound
so that a scalar property (ControlSource
in your case) can be bound via DataSource
and DataMember
properties.
For 3. use Tools->Procedure Attributes...
menu, select ControlSource
in Name, expand Advanced>>
and select Data in Property Category
combobox. You can do the same through Object Browser (F2). Find your control, right click your property/method (should be bold) and choose Properties...
context menu option. This works with methods and is more versatile than Tools->Procedure Attributes...
approach.
For 4. try setting your control's DataBindingBehavior
to vbSimpleBound
so that a scalar property (ControlSource
in your case) can be bound via DataSource
and DataMember
properties.
For 3. use Tools->Procedure Attributes...
menu, select ControlSource
in Name, expand Advanced>>
and select Data in Property Category
combobox. You can do the same through Object Browser (F2). Find your control, right click your property/method (should be bold) and choose Properties...
context menu option. This works with methods and is more versatile than Tools->Procedure Attributes...
approach.
edited Nov 11 '18 at 13:21
answered Nov 11 '18 at 12:23
wqwwqw
9,61512437
9,61512437
I have briefly tested your advices and binded myDataString
to theControl Source
. It wors great! But the bastard Access now refuses to display the form as Continuous: A form with a bound ActiveX control or an embedded object bound to a data source can't have its DefaultView property set to Continuous Forms. I have a bad feeling about this... Any sugestions?
– Combinatix
Nov 11 '18 at 13:07
1
@Combinatrix As shared in my answer, generally, it's hard to impossible to make an ActiveX control display something else for every row. Bound ActiveX controls aren't available on continuous subforms. However, you can try using theDetail_Paint
event to display something specific to the record being painted, but anything you do inDetail_Paint
that triggers a repaint causes an infinite loop (and things that change how objects are displayed often trigger a repaint of the entire form).
– Erik von Asmuth
Nov 11 '18 at 15:05
add a comment |
I have briefly tested your advices and binded myDataString
to theControl Source
. It wors great! But the bastard Access now refuses to display the form as Continuous: A form with a bound ActiveX control or an embedded object bound to a data source can't have its DefaultView property set to Continuous Forms. I have a bad feeling about this... Any sugestions?
– Combinatix
Nov 11 '18 at 13:07
1
@Combinatrix As shared in my answer, generally, it's hard to impossible to make an ActiveX control display something else for every row. Bound ActiveX controls aren't available on continuous subforms. However, you can try using theDetail_Paint
event to display something specific to the record being painted, but anything you do inDetail_Paint
that triggers a repaint causes an infinite loop (and things that change how objects are displayed often trigger a repaint of the entire form).
– Erik von Asmuth
Nov 11 '18 at 15:05
I have briefly tested your advices and binded my
DataString
to the Control Source
. It wors great! But the bastard Access now refuses to display the form as Continuous: A form with a bound ActiveX control or an embedded object bound to a data source can't have its DefaultView property set to Continuous Forms. I have a bad feeling about this... Any sugestions?– Combinatix
Nov 11 '18 at 13:07
I have briefly tested your advices and binded my
DataString
to the Control Source
. It wors great! But the bastard Access now refuses to display the form as Continuous: A form with a bound ActiveX control or an embedded object bound to a data source can't have its DefaultView property set to Continuous Forms. I have a bad feeling about this... Any sugestions?– Combinatix
Nov 11 '18 at 13:07
1
1
@Combinatrix As shared in my answer, generally, it's hard to impossible to make an ActiveX control display something else for every row. Bound ActiveX controls aren't available on continuous subforms. However, you can try using the
Detail_Paint
event to display something specific to the record being painted, but anything you do in Detail_Paint
that triggers a repaint causes an infinite loop (and things that change how objects are displayed often trigger a repaint of the entire form).– Erik von Asmuth
Nov 11 '18 at 15:05
@Combinatrix As shared in my answer, generally, it's hard to impossible to make an ActiveX control display something else for every row. Bound ActiveX controls aren't available on continuous subforms. However, you can try using the
Detail_Paint
event to display something specific to the record being painted, but anything you do in Detail_Paint
that triggers a repaint causes an infinite loop (and things that change how objects are displayed often trigger a repaint of the entire form).– Erik von Asmuth
Nov 11 '18 at 15:05
add a comment |
To answer your questions one by one:
Yes. ActiveX controls in Access are certainly different than in other Office applications.
In Access, there's one general CustomControl control that encapsulates all ActiveX controls, and offers a default set of events, properties and methods for any control, such as border properties, the requery method, and the enter event.
The object of the control being encapsulated can be accessed by using the
CustomControl.Object
proprtyThese properties aren't displayed because you're referring to a custom control in the general sense, and only get the properties for it.
To get the object you want, use the following:
Dim qrObj As QRCode
Set qrObj = QR.ObjectThat's plain not possible, tab layout is determined by Access
Also not possible. The ActiveX control must include that functionality, this one doesn't. Generally, using ActiveX controls in continuous subforms to display something different for every row is hard to impossible
Resizing the outer control, and then calling
CustomControl.SizeToFit
should generally just work
Some of the things I deem not possible can be achieved by modifying the ActiveX Control's source code, of course.
Rrright... Are you saying that Access'sCustomControl
wrapper have to understand my OCX's props and then it can propagate them to the right property tabs? I have the source code and I can do what I want with it (almost)
– Combinatix
Nov 11 '18 at 11:54
Yup, wqw just shared an answer on that
– Erik von Asmuth
Nov 11 '18 at 12:30
add a comment |
To answer your questions one by one:
Yes. ActiveX controls in Access are certainly different than in other Office applications.
In Access, there's one general CustomControl control that encapsulates all ActiveX controls, and offers a default set of events, properties and methods for any control, such as border properties, the requery method, and the enter event.
The object of the control being encapsulated can be accessed by using the
CustomControl.Object
proprtyThese properties aren't displayed because you're referring to a custom control in the general sense, and only get the properties for it.
To get the object you want, use the following:
Dim qrObj As QRCode
Set qrObj = QR.ObjectThat's plain not possible, tab layout is determined by Access
Also not possible. The ActiveX control must include that functionality, this one doesn't. Generally, using ActiveX controls in continuous subforms to display something different for every row is hard to impossible
Resizing the outer control, and then calling
CustomControl.SizeToFit
should generally just work
Some of the things I deem not possible can be achieved by modifying the ActiveX Control's source code, of course.
Rrright... Are you saying that Access'sCustomControl
wrapper have to understand my OCX's props and then it can propagate them to the right property tabs? I have the source code and I can do what I want with it (almost)
– Combinatix
Nov 11 '18 at 11:54
Yup, wqw just shared an answer on that
– Erik von Asmuth
Nov 11 '18 at 12:30
add a comment |
To answer your questions one by one:
Yes. ActiveX controls in Access are certainly different than in other Office applications.
In Access, there's one general CustomControl control that encapsulates all ActiveX controls, and offers a default set of events, properties and methods for any control, such as border properties, the requery method, and the enter event.
The object of the control being encapsulated can be accessed by using the
CustomControl.Object
proprtyThese properties aren't displayed because you're referring to a custom control in the general sense, and only get the properties for it.
To get the object you want, use the following:
Dim qrObj As QRCode
Set qrObj = QR.ObjectThat's plain not possible, tab layout is determined by Access
Also not possible. The ActiveX control must include that functionality, this one doesn't. Generally, using ActiveX controls in continuous subforms to display something different for every row is hard to impossible
Resizing the outer control, and then calling
CustomControl.SizeToFit
should generally just work
Some of the things I deem not possible can be achieved by modifying the ActiveX Control's source code, of course.
To answer your questions one by one:
Yes. ActiveX controls in Access are certainly different than in other Office applications.
In Access, there's one general CustomControl control that encapsulates all ActiveX controls, and offers a default set of events, properties and methods for any control, such as border properties, the requery method, and the enter event.
The object of the control being encapsulated can be accessed by using the
CustomControl.Object
proprtyThese properties aren't displayed because you're referring to a custom control in the general sense, and only get the properties for it.
To get the object you want, use the following:
Dim qrObj As QRCode
Set qrObj = QR.ObjectThat's plain not possible, tab layout is determined by Access
Also not possible. The ActiveX control must include that functionality, this one doesn't. Generally, using ActiveX controls in continuous subforms to display something different for every row is hard to impossible
Resizing the outer control, and then calling
CustomControl.SizeToFit
should generally just work
Some of the things I deem not possible can be achieved by modifying the ActiveX Control's source code, of course.
answered Nov 11 '18 at 10:19
Erik von AsmuthErik von Asmuth
18.9k62038
18.9k62038
Rrright... Are you saying that Access'sCustomControl
wrapper have to understand my OCX's props and then it can propagate them to the right property tabs? I have the source code and I can do what I want with it (almost)
– Combinatix
Nov 11 '18 at 11:54
Yup, wqw just shared an answer on that
– Erik von Asmuth
Nov 11 '18 at 12:30
add a comment |
Rrright... Are you saying that Access'sCustomControl
wrapper have to understand my OCX's props and then it can propagate them to the right property tabs? I have the source code and I can do what I want with it (almost)
– Combinatix
Nov 11 '18 at 11:54
Yup, wqw just shared an answer on that
– Erik von Asmuth
Nov 11 '18 at 12:30
Rrright... Are you saying that Access's
CustomControl
wrapper have to understand my OCX's props and then it can propagate them to the right property tabs? I have the source code and I can do what I want with it (almost)– Combinatix
Nov 11 '18 at 11:54
Rrright... Are you saying that Access's
CustomControl
wrapper have to understand my OCX's props and then it can propagate them to the right property tabs? I have the source code and I can do what I want with it (almost)– Combinatix
Nov 11 '18 at 11:54
Yup, wqw just shared an answer on that
– Erik von Asmuth
Nov 11 '18 at 12:30
Yup, wqw just shared an answer on that
– Erik von Asmuth
Nov 11 '18 at 12:30
add a comment |
A very different and much less cumbersome approach would be to generate the QR code online and download them to be displayed in a (bound) picture control.
I wrote an article on displaying online images:
Show pictures directly from URLs in Access forms and reports
Some code is, of course, needed, but much less than that at GiHub you refer to, though to much to list here in full.
It uses this function retrieve the images:
' Download (picture) file from a URL of a hyperlink field to a
' (temporary) folder, and return the full path to the downloaded file.
'
' This can be used as the control source for a bound picture control.
' If no Folder is specified, the user's IE cache folder is used.
'
' Typical usage in the RecordSource for a form or report where Id is
' the unique ID and Url is the hyperlink field holding the URL to
' the picture file to be displayed:
'
' - to a cached file where parameter Id is not used:
'
' Select *, UrlContent(0, [Url]) As Path From SomeTable;
'
' - or, where Id is used to create the local file name:
'
' Select *, UrlContent([Id], [Url], "d:somefolder") As Path From SomeTable;
'
' Then, set ControlSource of the bound picture control to: Path
'
' 2017-05-28. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function UrlContent( _
ByVal Id As Long, _
ByVal Url As String, _
Optional ByVal Folder As String) _
As Variant
Const NoError As Long = 0
Const Dot As String = "."
Const BackSlash As String = ""
Dim Address As String
Dim Ext As String
Dim Path As String
Dim Result As String
' Strip leading and trailing octothorpes from URL string.
Address = HyperlinkPart(Url, acAddress)
' If Address is a zero-length string, Url was not wrapped in octothorpes.
If Address = "" Then
' Use Url as is.
Address = Url
End If
If Folder = "" Then
' Import to IE cache.
Result = DownloadCacheFile(Address)
Else
If Right(Folder, 1) <> BackSlash Then
' Append a backslash.
Folder = Folder & BackSlash
End If
' Retrieve extension of file name.
Ext = StrReverse(Split(StrReverse(Address), Dot)(0))
' Build full path for downloaded file.
Path = Folder & CStr(Id) & Dot & Ext
If DownloadFile(Address, Path) = NoError Then
Result = Path
End If
End If
UrlContent = Result
End Function
I pasted this URL into a record:
https://chart.googleapis.com/chart?cht=qr&chs=300x300&chl=23457
and it worked right away:
Full code can be found at GitHub: VBA.PictureUrl
I have used your Scenario 1 - Download and Display in the past. However this does not really answer my questions. My current OCX works almost perfect and after placing it to new access database it requires only one line of VBAQR.DataString = Me!SomeField
. Also, the database stays internet-independend. The goal of my question was to find out how to insert Access-specific features into an OCX.
– Combinatix
Nov 11 '18 at 11:07
1
I've only worked with third-party OCX and don't have VB6, so I have no clue, sorry. Just wanted to make sure, you were aware of an alternative. Also, the use of OCX has decreased as they usually don't work with 64-bit Access.
– Gustav
Nov 11 '18 at 11:27
add a comment |
A very different and much less cumbersome approach would be to generate the QR code online and download them to be displayed in a (bound) picture control.
I wrote an article on displaying online images:
Show pictures directly from URLs in Access forms and reports
Some code is, of course, needed, but much less than that at GiHub you refer to, though to much to list here in full.
It uses this function retrieve the images:
' Download (picture) file from a URL of a hyperlink field to a
' (temporary) folder, and return the full path to the downloaded file.
'
' This can be used as the control source for a bound picture control.
' If no Folder is specified, the user's IE cache folder is used.
'
' Typical usage in the RecordSource for a form or report where Id is
' the unique ID and Url is the hyperlink field holding the URL to
' the picture file to be displayed:
'
' - to a cached file where parameter Id is not used:
'
' Select *, UrlContent(0, [Url]) As Path From SomeTable;
'
' - or, where Id is used to create the local file name:
'
' Select *, UrlContent([Id], [Url], "d:somefolder") As Path From SomeTable;
'
' Then, set ControlSource of the bound picture control to: Path
'
' 2017-05-28. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function UrlContent( _
ByVal Id As Long, _
ByVal Url As String, _
Optional ByVal Folder As String) _
As Variant
Const NoError As Long = 0
Const Dot As String = "."
Const BackSlash As String = ""
Dim Address As String
Dim Ext As String
Dim Path As String
Dim Result As String
' Strip leading and trailing octothorpes from URL string.
Address = HyperlinkPart(Url, acAddress)
' If Address is a zero-length string, Url was not wrapped in octothorpes.
If Address = "" Then
' Use Url as is.
Address = Url
End If
If Folder = "" Then
' Import to IE cache.
Result = DownloadCacheFile(Address)
Else
If Right(Folder, 1) <> BackSlash Then
' Append a backslash.
Folder = Folder & BackSlash
End If
' Retrieve extension of file name.
Ext = StrReverse(Split(StrReverse(Address), Dot)(0))
' Build full path for downloaded file.
Path = Folder & CStr(Id) & Dot & Ext
If DownloadFile(Address, Path) = NoError Then
Result = Path
End If
End If
UrlContent = Result
End Function
I pasted this URL into a record:
https://chart.googleapis.com/chart?cht=qr&chs=300x300&chl=23457
and it worked right away:
Full code can be found at GitHub: VBA.PictureUrl
I have used your Scenario 1 - Download and Display in the past. However this does not really answer my questions. My current OCX works almost perfect and after placing it to new access database it requires only one line of VBAQR.DataString = Me!SomeField
. Also, the database stays internet-independend. The goal of my question was to find out how to insert Access-specific features into an OCX.
– Combinatix
Nov 11 '18 at 11:07
1
I've only worked with third-party OCX and don't have VB6, so I have no clue, sorry. Just wanted to make sure, you were aware of an alternative. Also, the use of OCX has decreased as they usually don't work with 64-bit Access.
– Gustav
Nov 11 '18 at 11:27
add a comment |
A very different and much less cumbersome approach would be to generate the QR code online and download them to be displayed in a (bound) picture control.
I wrote an article on displaying online images:
Show pictures directly from URLs in Access forms and reports
Some code is, of course, needed, but much less than that at GiHub you refer to, though to much to list here in full.
It uses this function retrieve the images:
' Download (picture) file from a URL of a hyperlink field to a
' (temporary) folder, and return the full path to the downloaded file.
'
' This can be used as the control source for a bound picture control.
' If no Folder is specified, the user's IE cache folder is used.
'
' Typical usage in the RecordSource for a form or report where Id is
' the unique ID and Url is the hyperlink field holding the URL to
' the picture file to be displayed:
'
' - to a cached file where parameter Id is not used:
'
' Select *, UrlContent(0, [Url]) As Path From SomeTable;
'
' - or, where Id is used to create the local file name:
'
' Select *, UrlContent([Id], [Url], "d:somefolder") As Path From SomeTable;
'
' Then, set ControlSource of the bound picture control to: Path
'
' 2017-05-28. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function UrlContent( _
ByVal Id As Long, _
ByVal Url As String, _
Optional ByVal Folder As String) _
As Variant
Const NoError As Long = 0
Const Dot As String = "."
Const BackSlash As String = ""
Dim Address As String
Dim Ext As String
Dim Path As String
Dim Result As String
' Strip leading and trailing octothorpes from URL string.
Address = HyperlinkPart(Url, acAddress)
' If Address is a zero-length string, Url was not wrapped in octothorpes.
If Address = "" Then
' Use Url as is.
Address = Url
End If
If Folder = "" Then
' Import to IE cache.
Result = DownloadCacheFile(Address)
Else
If Right(Folder, 1) <> BackSlash Then
' Append a backslash.
Folder = Folder & BackSlash
End If
' Retrieve extension of file name.
Ext = StrReverse(Split(StrReverse(Address), Dot)(0))
' Build full path for downloaded file.
Path = Folder & CStr(Id) & Dot & Ext
If DownloadFile(Address, Path) = NoError Then
Result = Path
End If
End If
UrlContent = Result
End Function
I pasted this URL into a record:
https://chart.googleapis.com/chart?cht=qr&chs=300x300&chl=23457
and it worked right away:
Full code can be found at GitHub: VBA.PictureUrl
A very different and much less cumbersome approach would be to generate the QR code online and download them to be displayed in a (bound) picture control.
I wrote an article on displaying online images:
Show pictures directly from URLs in Access forms and reports
Some code is, of course, needed, but much less than that at GiHub you refer to, though to much to list here in full.
It uses this function retrieve the images:
' Download (picture) file from a URL of a hyperlink field to a
' (temporary) folder, and return the full path to the downloaded file.
'
' This can be used as the control source for a bound picture control.
' If no Folder is specified, the user's IE cache folder is used.
'
' Typical usage in the RecordSource for a form or report where Id is
' the unique ID and Url is the hyperlink field holding the URL to
' the picture file to be displayed:
'
' - to a cached file where parameter Id is not used:
'
' Select *, UrlContent(0, [Url]) As Path From SomeTable;
'
' - or, where Id is used to create the local file name:
'
' Select *, UrlContent([Id], [Url], "d:somefolder") As Path From SomeTable;
'
' Then, set ControlSource of the bound picture control to: Path
'
' 2017-05-28. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function UrlContent( _
ByVal Id As Long, _
ByVal Url As String, _
Optional ByVal Folder As String) _
As Variant
Const NoError As Long = 0
Const Dot As String = "."
Const BackSlash As String = ""
Dim Address As String
Dim Ext As String
Dim Path As String
Dim Result As String
' Strip leading and trailing octothorpes from URL string.
Address = HyperlinkPart(Url, acAddress)
' If Address is a zero-length string, Url was not wrapped in octothorpes.
If Address = "" Then
' Use Url as is.
Address = Url
End If
If Folder = "" Then
' Import to IE cache.
Result = DownloadCacheFile(Address)
Else
If Right(Folder, 1) <> BackSlash Then
' Append a backslash.
Folder = Folder & BackSlash
End If
' Retrieve extension of file name.
Ext = StrReverse(Split(StrReverse(Address), Dot)(0))
' Build full path for downloaded file.
Path = Folder & CStr(Id) & Dot & Ext
If DownloadFile(Address, Path) = NoError Then
Result = Path
End If
End If
UrlContent = Result
End Function
I pasted this URL into a record:
https://chart.googleapis.com/chart?cht=qr&chs=300x300&chl=23457
and it worked right away:
Full code can be found at GitHub: VBA.PictureUrl
answered Nov 11 '18 at 9:38
GustavGustav
29.6k51734
29.6k51734
I have used your Scenario 1 - Download and Display in the past. However this does not really answer my questions. My current OCX works almost perfect and after placing it to new access database it requires only one line of VBAQR.DataString = Me!SomeField
. Also, the database stays internet-independend. The goal of my question was to find out how to insert Access-specific features into an OCX.
– Combinatix
Nov 11 '18 at 11:07
1
I've only worked with third-party OCX and don't have VB6, so I have no clue, sorry. Just wanted to make sure, you were aware of an alternative. Also, the use of OCX has decreased as they usually don't work with 64-bit Access.
– Gustav
Nov 11 '18 at 11:27
add a comment |
I have used your Scenario 1 - Download and Display in the past. However this does not really answer my questions. My current OCX works almost perfect and after placing it to new access database it requires only one line of VBAQR.DataString = Me!SomeField
. Also, the database stays internet-independend. The goal of my question was to find out how to insert Access-specific features into an OCX.
– Combinatix
Nov 11 '18 at 11:07
1
I've only worked with third-party OCX and don't have VB6, so I have no clue, sorry. Just wanted to make sure, you were aware of an alternative. Also, the use of OCX has decreased as they usually don't work with 64-bit Access.
– Gustav
Nov 11 '18 at 11:27
I have used your Scenario 1 - Download and Display in the past. However this does not really answer my questions. My current OCX works almost perfect and after placing it to new access database it requires only one line of VBA
QR.DataString = Me!SomeField
. Also, the database stays internet-independend. The goal of my question was to find out how to insert Access-specific features into an OCX.– Combinatix
Nov 11 '18 at 11:07
I have used your Scenario 1 - Download and Display in the past. However this does not really answer my questions. My current OCX works almost perfect and after placing it to new access database it requires only one line of VBA
QR.DataString = Me!SomeField
. Also, the database stays internet-independend. The goal of my question was to find out how to insert Access-specific features into an OCX.– Combinatix
Nov 11 '18 at 11:07
1
1
I've only worked with third-party OCX and don't have VB6, so I have no clue, sorry. Just wanted to make sure, you were aware of an alternative. Also, the use of OCX has decreased as they usually don't work with 64-bit Access.
– Gustav
Nov 11 '18 at 11:27
I've only worked with third-party OCX and don't have VB6, so I have no clue, sorry. Just wanted to make sure, you were aware of an alternative. Also, the use of OCX has decreased as they usually don't work with 64-bit Access.
– Gustav
Nov 11 '18 at 11:27
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244605%2fmaking-qrcode-activex-control-for-ms-access-control-source-property%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If interested, here is an alternative
– krish KM
Nov 12 '18 at 13:33