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:
OnClick
are not displayed at tab Event of Property SheetHere are my questions:
ForeRGB
to tab Format (as usual for TextBoxes etc.)?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.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
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.