Making QRCode ActiveX Control for MS Access: Control Source Property











up vote
4
down vote

favorite












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:
Excel printscreen



This is how it looks in Access:
MS Access printscreen




  • 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:




  1. Are the Controls for Access "different" than for other office apps?

  2. Why the hell are the properties hidden in editor?

  3. How to "move" some properties to other tabs (categories), for example ForeRGB to tab Format (as usual for TextBoxes etc.)?

  4. 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.

  5. 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










share|improve this question
























  • If interested, here is an alternative
    – krish KM
    Nov 12 at 13:33















up vote
4
down vote

favorite












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:
Excel printscreen



This is how it looks in Access:
MS Access printscreen




  • 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:




  1. Are the Controls for Access "different" than for other office apps?

  2. Why the hell are the properties hidden in editor?

  3. How to "move" some properties to other tabs (categories), for example ForeRGB to tab Format (as usual for TextBoxes etc.)?

  4. 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.

  5. 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










share|improve this question
























  • If interested, here is an alternative
    – krish KM
    Nov 12 at 13:33













up vote
4
down vote

favorite









up vote
4
down vote

favorite











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:
Excel printscreen



This is how it looks in Access:
MS Access printscreen




  • 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:




  1. Are the Controls for Access "different" than for other office apps?

  2. Why the hell are the properties hidden in editor?

  3. How to "move" some properties to other tabs (categories), for example ForeRGB to tab Format (as usual for TextBoxes etc.)?

  4. 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.

  5. 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










share|improve this question















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:
Excel printscreen



This is how it looks in Access:
MS Access printscreen




  • 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:




  1. Are the Controls for Access "different" than for other office apps?

  2. Why the hell are the properties hidden in editor?

  3. How to "move" some properties to other tabs (categories), for example ForeRGB to tab Format (as usual for TextBoxes etc.)?

  4. 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.

  5. 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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 at 19:50

























asked Nov 10 at 23:58









Combinatix

4981717




4981717












  • If interested, here is an alternative
    – krish KM
    Nov 12 at 13:33


















  • If interested, here is an alternative
    – krish KM
    Nov 12 at 13:33
















If interested, here is an alternative
– krish KM
Nov 12 at 13:33




If interested, here is an alternative
– krish KM
Nov 12 at 13:33












3 Answers
3






active

oldest

votes

















up vote
1
down vote



accepted










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.






share|improve this answer























  • 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 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 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 at 15:05


















up vote
1
down vote













To answer your questions one by one:





  1. 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 proprty




  2. These 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.Object


  3. That's plain not possible, tab layout is determined by Access


  4. 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


  5. 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.






share|improve this answer





















  • 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 at 11:54












  • Yup, wqw just shared an answer on that
    – Erik von Asmuth
    Nov 11 at 12:30


















up vote
0
down vote













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:



Sample



Full code can be found at GitHub: VBA.PictureUrl






share|improve this answer





















  • 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 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 at 11:27











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',
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
});


}
});














 

draft saved


draft discarded


















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








up vote
1
down vote



accepted










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.






share|improve this answer























  • 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 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 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 at 15:05















up vote
1
down vote



accepted










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.






share|improve this answer























  • 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 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 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 at 15:05













up vote
1
down vote



accepted







up vote
1
down vote



accepted






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.






share|improve this answer














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.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 11 at 13:21

























answered Nov 11 at 12:23









wqw

9,58512437




9,58512437












  • 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 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 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 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 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 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 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 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 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 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 at 15:05












up vote
1
down vote













To answer your questions one by one:





  1. 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 proprty




  2. These 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.Object


  3. That's plain not possible, tab layout is determined by Access


  4. 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


  5. 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.






share|improve this answer





















  • 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 at 11:54












  • Yup, wqw just shared an answer on that
    – Erik von Asmuth
    Nov 11 at 12:30















up vote
1
down vote













To answer your questions one by one:





  1. 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 proprty




  2. These 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.Object


  3. That's plain not possible, tab layout is determined by Access


  4. 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


  5. 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.






share|improve this answer





















  • 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 at 11:54












  • Yup, wqw just shared an answer on that
    – Erik von Asmuth
    Nov 11 at 12:30













up vote
1
down vote










up vote
1
down vote









To answer your questions one by one:





  1. 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 proprty




  2. These 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.Object


  3. That's plain not possible, tab layout is determined by Access


  4. 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


  5. 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.






share|improve this answer












To answer your questions one by one:





  1. 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 proprty




  2. These 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.Object


  3. That's plain not possible, tab layout is determined by Access


  4. 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


  5. 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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 11 at 10:19









Erik von Asmuth

17.8k41938




17.8k41938












  • 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 at 11:54












  • Yup, wqw just shared an answer on that
    – Erik von Asmuth
    Nov 11 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 at 11:54












  • Yup, wqw just shared an answer on that
    – Erik von Asmuth
    Nov 11 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 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 at 11:54














Yup, wqw just shared an answer on that
– Erik von Asmuth
Nov 11 at 12:30




Yup, wqw just shared an answer on that
– Erik von Asmuth
Nov 11 at 12:30










up vote
0
down vote













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:



Sample



Full code can be found at GitHub: VBA.PictureUrl






share|improve this answer





















  • 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 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 at 11:27















up vote
0
down vote













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:



Sample



Full code can be found at GitHub: VBA.PictureUrl






share|improve this answer





















  • 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 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 at 11:27













up vote
0
down vote










up vote
0
down vote









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:



Sample



Full code can be found at GitHub: VBA.PictureUrl






share|improve this answer












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:



Sample



Full code can be found at GitHub: VBA.PictureUrl







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 11 at 9:38









Gustav

28.9k51734




28.9k51734












  • 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 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 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 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 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 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 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 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 at 11:27


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma