Color scheme: Light
You are here: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » WKL Forms Object Library API reference » WklBarcode

WklBarcode

WklBarcode class

Signature

Dim myWklBarcode As WklBarcode
Set myWklBarcode = Me!ControlName.Object

Summary

A QR Code, Code 128 or Data Matrix symbol of a text, drawn from encoders of its own (no external library), in forms, in reports and on UserForms.

Parameters

None

Remarks

Fill it like WklStatusLabel: by code through Value, or bound - set the control's Control Source (ControlSource of the Access control) to a field or an expression, and Access writes the value of the current record into Value. A bound barcode never writes back and does not mark the record as changed.

Reports. In the detail section of a report a bound barcode draws the code of each record, in print preview and in a PDF from DoCmd.OutputTo. This is the way to a label with a code per record; no code in Detail_Format is needed.

A value the symbology cannot encode - a letter with an accent for Code 128, the euro sign for Data Matrix - is no error for the form or the report: the control shows the reason instead of a symbol and ErrorText returns it, so one bad record does not stop a list of labels.

The modules are drawn as filled rectangles in whole pixels where they fit, centered in the control; on a printer the code is drawn at 300 dpi, so its edges stay sharp. Black on white is the default, and the control has no color scheme: scanners need contrast, not the database design. Give a QR Code or a Data Matrix symbol a square control; a Code 128 symbol fills the height of its control.

The designer (row Custom [...] of the property sheet in design view, Opening the designer) sets kind, error correction, text and quiet zone with a preview of a sample text, and colors and font; it warns when the modules are not clearly darker than the background.

An ActiveX control: inserted into a form in design view (Form Design › Controls › ActiveX Controls); reports are not supported. VBA reaches it through the Object property of the control, where ControlName is the name of the control on the form.

MemberKindSummary
`Value`PropertyGets or sets the text of the code; bound, Access writes the value of the Control Source into it on every record change.
`Symbology`PropertyGets or sets the kind of code.
`ErrorCorrection`PropertyGets or sets how much of a QR Code may be damaged and still be read.
`ShowText`PropertyGets or sets whether the text stands readable below the code.
`QuietZone`PropertyGets or sets the free margin around the code, in modules.
`ForeColor`PropertyGets or sets the color of the dark modules and of the text.
`BackColor`PropertyGets or sets the background color.
`FontName`PropertyGets or sets the font of the text below the code.
`FontSize`PropertyGets or sets the size of the text below the code.
`ErrorText`PropertyGets why the current value cannot be shown as a code.
`ModuleCount`PropertyGets the number of modules in one row of the current code.
`SaveImage`MethodWrites the code of a text as a picture file.
EventSummary
`Click`Occurs when the user clicks the code in form view.

Code example

' Bound in design view: Control Source of bcdProduct = ProductNo.
' By code, for example in an unbound form:
Private Sub cmdCode_Click()
    With Me!bcdProduct.Object
        .Symbology = wsyCode128
        .ShowText = True
        .Value = Me!txtProductNo
        If Len(.ErrorText) > 0 Then MsgBox .ErrorText, vbExclamation
    End With
End Sub

Inheritance

None

Value property

Signature

Property Get Value() As Variant
Property Let Value(RHS As Variant)

Summary

Gets or sets the text of the code; bound, Access writes the value of the Control Source into it on every record change.

Parameters

None

Property value: Variant – Any value; numbers and dates are encoded as their text in the regional settings of Windows. Null or an empty text shows nothing.

Remarks

The value is not stored with the form, and the control never reports it back to Access. After a value is set, ErrorText says whether it could be encoded.

Read/write.

Code example

None

Inheritance

Declared by WklBarcode.

Symbology property

Signature

Property Get Symbology() As WklSymbology
Property Let Symbology(RHS As WklSymbology)

Summary

Gets or sets the kind of code.

Parameters

None

Property value: `WklSymbology` – wsyQrCode (default), wsyCode128 or wsyDataMatrix.

Remarks

QR Code encodes any text (as UTF-8; digits and capital letters take less room). Code 128 encodes ASCII only (characters 0-127) and switches between its code sets for the shortest symbol. Data Matrix (ECC 200, square) encodes ISO-8859-1, which includes the German umlauts but not the euro sign. Values outside the enumeration raise wkeInvalidValue.

Read/write.

Code example

None

Inheritance

Declared by WklBarcode.

ErrorCorrection property

Signature

Property Get ErrorCorrection() As WklErrorCorrection
Property Let ErrorCorrection(RHS As WklErrorCorrection)

Summary

Gets or sets how much of a QR Code may be damaged and still be read.

Parameters

None

Property value: `WklErrorCorrection` – wecLow, wecMedium (default), wecQuartile or wecHigh.

Remarks

A higher level makes the code larger for the same text. Only QR Code uses it; Code 128 has a check character, and Data Matrix ECC 200 has a fixed error correction. Values outside the enumeration raise wkeInvalidValue.

Read/write.

Code example

None

Inheritance

Declared by WklBarcode.

ShowText property

Signature

Property Get ShowText() As Boolean
Property Let ShowText(RHS As Boolean)

Summary

Gets or sets whether the text stands readable below the code.

Parameters

None

Property value: Boolean – True: the text below the code, in FontName and FontSize; False (default).

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklBarcode.

QuietZone property

Signature

Property Get QuietZone() As Long
Property Let QuietZone(RHS As Long)

Summary

Gets or sets the free margin around the code, in modules.

Parameters

None

Property value: Long – -1 (default) for the margin the standard asks for (QR Code 4, Code 128 10, Data Matrix 1 module); 0 to 100 for another one.

Remarks

Scanners need the quiet zone; reduce it only where the space around the control is free anyway. Values outside -1 to 100 raise wkeInvalidValue.

Read/write.

Code example

None

Inheritance

Declared by WklBarcode.

ForeColor property

Signature

Property Get ForeColor() As OLE_COLOR
Property Let ForeColor(RHS As OLE_COLOR)

Summary

Gets or sets the color of the dark modules and of the text.

Parameters

None

Property value: OLE_COLOR – An OLE color; default black.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklBarcode.

BackColor property

Signature

Property Get BackColor() As OLE_COLOR
Property Let BackColor(RHS As OLE_COLOR)

Summary

Gets or sets the background color.

Parameters

None

Property value: OLE_COLOR – An OLE color; default white.

Remarks

Most scanners read only dark modules on a light background; the designer warns about other choices.

Read/write.

Code example

None

Inheritance

Declared by WklBarcode.

FontName property

Signature

Property Get FontName() As String
Property Let FontName(RHS As String)

Summary

Gets or sets the font of the text below the code.

Parameters

None

Property value: String – A font name; default "Segoe UI". An empty name raises wkeInvalidValue.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklBarcode.

FontSize property

Signature

Property Get FontSize() As Long
Property Let FontSize(RHS As Long)

Summary

Gets or sets the size of the text below the code.

Parameters

None

Property value: Long – Points, 6 to 72; default 9. Other values raise wkeInvalidValue.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklBarcode.

ErrorText property

Signature

Property Get ErrorText() As String

Summary

Gets why the current value cannot be shown as a code.

Parameters

None

Property value: String – The reason, for example which character Code 128 cannot encode; empty when the value is encoded or there is no value.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklBarcode.

ModuleCount property

Signature

Property Get ModuleCount() As Long

Summary

Gets the number of modules in one row of the current code.

Parameters

None

Property value: Long – The width of the symbol in modules, without the quiet zone (21 for the smallest QR Code); 0 without a code.

Remarks

Divide the control's width by ModuleCount plus twice the quiet zone to see how many pixels or twips one module gets; scanners need at least about 0.25 mm per module in print.

Read-only.

Code example

None

Inheritance

Declared by WklBarcode.

SaveImage method

Signature

Sub SaveImage(ByVal Path As String, Optional ByVal Text As String = "", Optional ByVal ModuleSize As Long = 4)

Summary

Writes the code of a text as a picture file.

Parameters

NameTypeOptionalDefaultDescription
PathStringNo–The file; its extension sets the format: .png or .bmp.
TextStringYes""The text to encode; empty (default) for the current value.
ModuleSizeLongYes4Pixels per module, 1 to 50; default 4.

Remarks

The picture uses the control's kind, error correction, quiet zone, colors and text settings; a Code 128 symbol is 60 modules high. SaveImage also works on an object made with CreateObject("WklForms.Barcode"), without a form. Another extension, a module size outside 1-50, no text, or a text the kind cannot encode raise wkeInvalidValue; a file that cannot be written raises wkeSourceError.

Code example

None

Inheritance

Declared by WklBarcode.

Click event

Signature

Event Click()

Summary

Occurs when the user clicks the code in form view.

Parameters

None

Remarks

In a form module: Private Sub <ControlName>_Click(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklBarcode.

en/wiki/msaccess/comctl/api-reference/wklbarcode.txt · Last modified: by Wolfgang van der Stille