Lebans Holdings 1999 Ltd.

 Home ] Up ] Feedback ] Contents ] Search ] What's New ] 

Forms
Home
Up
Forms
Reports
List/Combo Boxes
ActiveX Controls
MISC
VisualBasic
MSWord

RETIRED! September 2009

I have officially retired from all things Access. Please do not send Email requesting support as I will not respond.

 

Keep all of your questions to the Newsgroups where everyone will benefit!

 

 

 

The following items cover topics related to Access Forms and their use.

CopyGetRTFfromClipboardA2K demonstrates how to copy and get RTF from the Clipboard. Requires Microsoft Rich Edit ActiveX control to view results but not for full functionality.

RichTextActiveXControl is an ActiveX RTF solution written in VC++. The RTF2 control is a complete editing/printing solution for Access 97 or higher. Autosizing of the RTF2 control is supported for A2K or higher.

A2KSHTML is an HTML Editor built around the MS Web Browser control. A2K or higher ONLY!!!!

RecordNavigationButtons is an MDB containing code to replace the standard Navigation Buttons. The custom bottons exactly emulate the standard navigation bar including the autorepeat property.

ChangeMDIBackGround is a database containing a function to allow you to specify a color for the background of the main Access MDI window.

AutosizeOLE is a database containing functionality to allow for the auto sizing of bound or unbound OLE Frame controls. A2K or A97.

A2KConditionalFormatting is a sample MDB demonstrating how to programmatically setup Conditional Formatting to simulate:1) Highlighting of the Current Row for a Form in Continuous or Datasheet View. 2) Highlighting of Alternate Rows for a Form in Continuous or Datasheet View

ContinuousFormsCurrentRow is a class that allows you to programmatically access the contents of a bound control, as the user moves their Mouse, but the control does not have the focus. For Forms in Continuous View.

AlternateColorDetailSection is a class to allow for alternate bands of color for Forms in Continuous View.

MouseWheelOnOff is a database containing sample code to enable the user/develop to programmatically turn on or turn off the MouseWheel.

TextHeightWidth is a replacement for the Report object's TextWidth and TextHeight methods. It is multiline aware and can work in both Report and Form views.

ToolTip is a database containing a custom ToolTip class. Enhanced features include Selectable delay times for Toolltip to first appear, Selectable delay times for Tooltip to dissappear, Selectable Text Color, Selectable Background Color, Selectable Margins, Specify Tooltip size, Add a title to the Tooltip in Bold
Selectable Icon for the Tooltip, ToolTips for Lines, Boxes, any rectangular area on your Form.

PictureBox is a database containing a class to enhance the standard Image control. This allows the control to resemble the standard Visual Basic PictureBox control. Simple drawing methods are directly supported as is Text output with rotation. A handle to a Device Context is exposed to allow the developer to use the full range of Graphic API's.

TabColors is an MDB containing a class to enhance the standard Access TAB control in order to allow for Tabs of any color and Rotated Text.

LoadSaveJpeg contains a database demonstrating how to use the Intel Jpeg library with Access. Jpeg files are stored in their original compressed state within a Binary OLE avoiding the Ole object "bloat" issue. The contents of the Image control, containing any supported source Image format, can be saved to disk as a Jpeg file.

FormDimensions is a database containing a Form that demonstrates the relationships of the Form and Section Height and Width properties.

SelectAlpha is a database containing a function demonstrating how to use a Label control filled with the Letters of the alphabet to implement a single character filter for your Form.

RichText is a database containing a class that allows for the display of RTF text within a standard Access Image control. No RTF ActiveX control is required.

AutoColumnWidth is a Database containing functions to enable auto sizing of Columns in Form Datasheet view by clicking on the Column Header. Access offers this function but only for the rows of the Datasheet that are currently in view. AutoColumnWidth checks every row of the Datasheet to calculate the final width required to completely display the contents in every row.

MonthCalendar New Version 3 A database containing a Class that wraps the Microsoft Common Control Month Calendar in an easy to use interface. This is a completely API generated Month Calendar derived directly from the Common Control DLL. What this means is that there are no distribution or versioning issues as there are if you use the ActiveX DatePicker control.

AutoUpDown is a database containing functionality to allow the user to use the "+" or "-" minus keys to increment/decrement the values in a control. Automatically recognizes Numeric, Date and Time formats. Also allows the user to enter/edit a value in a control and continue incrementing/decrementing without first having to save or exit the control.

AnimateForm is a database containing a Class that has functionality to animate a Form during opening and closing. Demonstrates use of WithEvents to sink several events on a Form.

AutoSizeFont is a database containing a function to automatically resize a Control's Font to fit the current record's contents. Works in the Form's Current and/or Change events.

LimitTextInput is a database containing a functions to limit the input into a TextBox control. Will allow data input that will fit within the current displayable area of the control only.

NEW  CanGrow Ver 1.0 is a database containing functions to simulate CanGrow/CanShrink for Forms in Form View. 

ImageControlToClipBoard is a database containing a function that allows you to copy the contents of a standard Image Control to the ClipBoard.

Updated Ver 5.0  LoadJpegGif - Developed to allow Access RunTime installations to display Jpeg files in a standard Image Control. Provides functionality to load JPG,GIF,BMP,EMF,WMF,CUR and ICO  files on systems without the Office Graphics Filters loaded.  Supports transparency in Transparent Gifs.  Allows you to resize Images on Forms/Reports at runtime  with no loss of Image quality.

AnimatedGif Ver 3.0 BETA contains source code for a VB Animated Gif Player. THis version supports Local Color Tables and enhanced Transparency support. No external ActiveX or 3'rd party DLL's required. Jan 23, 2001 New VB6 Source.

Transparent is a database containing functions to allow for the conversion of Bitmap, Gif, Jpeg, Enhanced Metafile and Metafile to an Enhanced Metafile format supporting Transparent backgrounds.

SetGetSB is a database containing functions to allow a user to programmatically set the position of a Form's Scrollbar in Continuous Forms or Datasheet view. 

CommandButton is a database containing functions to allow a user defined BackColor and Rotated Text for Command Buttons. 

FormatbyCriteriaSubClass is a database containing functions to allow Criteria based formatting a Form in Continuous Form's View. Unlimited colors and criteria. 

PaintProgram - The most simple of all Paint Programs! Native VBA no API's.

ZoomInOut - Add Zoom In/out to your Image control & More! 

AutoSizeTextBox - Uses On Current event to resize TextBox to fit the data

ImageClass - Wrapper for Image Control allows for drawing at Runtime. Simulates a Visual basic PictureBox control.

NEW RotateTextWMF - Updated VBA Rotate Text program. Now use at Design or Runtime!

Limit Characters in a Memo Field - Just like it says :-) 

Magnify Design View - Magnify area under cursor in Form or Design View

Select A Row in a Form/SubForm - Just like it says :-) 

 

Raw NewsGroup Postings

Actually change the TextBox Text property in the BeforeUpdate event.

A very fast updated Screen Counter

Add a Custom Property to your Form

 

When I first started seriously with Access I had a hell of time
understanding the BeforeUpdate event. I kept trying to change the value
of the control if it failed my validation logic. I finally learned that
you cannot change the .Value or the .Text property inside of the
BeforeUpdate event. What you can do is set
Cancel = True
Me.ctl.Undo

This will leave the focus in the control and reset what's displayed to
what was there when we entered the control. Any changes to the .Text or
.Value property just need to wait for the AfterUpdate event or some
other event.

But what if the user needs a nudge to help their data entry pass/conform
to our Validation processing. Well we can obviously use:
1) Validation rules at the field or control level
2) Pop a MessageBox explaining the "Rules" of our data entry game.

The above probably works for 95% of the data entry situations you'd ever
encounter. Most anything else you can manage in the control's
AfterUpdate event. So what the hell am I rambling on about?

Well, as this was my first roadblock in learning Access, I promised
myself one day I'd find a way around it..just out of spite mind you.
Really no practical application I know of, but I'm not exactly what you
call a Developer with broad experience. :-)

Add a TextBox control named Text0 to a Form.

'Place these 2 declarations in the Forms General Declaration section.
Private Declare Function GetFocus Lib "user32" () As Long

Private Declare Function SetWindowText Lib "user32" Alias
"SetWindowTextA" (ByVal hwnd _
As Long, ByVal lpString As String) As Long


Private Sub Text0_BeforeUpdate(Cancel As Integer)
    Dim Hwnd As Long
    Dim lngResult As Long
    Dim strTest As String,

    ' Get the window handle for the current window.
    ' That's this TextBox's Window
    Hwnd = GetFocus()

    'Put the text you want displayed in the control here.
    strTest = "Stephen"

    'MessageBox is just for Debugging
    lngResult = MsgBox("Update TextBox", vbYesNo)
    If lngResult = vbNo Then Cancel = True

    ' Send the message to the current text box
    ' Updates the TEXT property
    lngResult = SetWindowText(hwnd, strTest)

End Sub


This seems to work on both Bound or Unbound controls. I had some
problems at first with only being able to send characters = the current
length of the string/(num chars) displayed in the control at GotFocus
time.
Seems OK on Bound controls now.

 

Private Declare Function GetFocus Lib "user32" () As Long

Private Declare Function SetWindowText Lib "user32" Alias
"SetWindowTextA" (ByVal Hwnd _
As Long, ByVal lpString As String) As Long


Private Sub Text0_Click()
  Dim a As Long
  Dim Hwnd As Long
    Dim lngResult As Long
    Dim strTest As String

  ' Get the window handle for the current window.
    ' That's this TextBox's Window
    Hwnd = GetFocus()

  Debug.Print Now
  'DoEvents
  For a = 0 To 10000 Step 1
'Me.Text0 = a
 'Me.Repaint
 'DoEvents
 ' Send the message to the current text box
    ' Updates the TEXT property
  lngResult = SetWindowText(Hwnd, a)

  Next a

Debug.Print Now
End Sub


OK Billy, with a loop of 10,000, displaying every single number from 1
to 10,000..no skipping..no cheating, run 10 times to verify:
DoEvents:  16 seconds
Me.Repaint:  8 seconds
SetWindowText: 2 Seconds

 

 

Option Compare Database
Option Explicit

' Thanks you to Dimitri Furman for the
' initial code I brutalized to produce
' this example. :-)


Private Sub Box1_Click()
Dim x As Integer
x = 1
WriteIconFile
ReadIconFile

End Sub




Private Function WriteIconFile() As String
'reads a binary property of the form and writes it as an icon file
'to temp directory. Returns path to the file.
On Error GoTo Err_Handler
Dim intFile As Integer
Dim abytFileData() As Byte
Dim strFilePath As String
Dim lngDataLength As Long
Dim db As DAO.Database
Dim docForm As DAO.Document
Dim prop As Property
Dim bArray(1 To 1000) As Byte
Dim x As Long

For x = 1 To UBound(bArray)
bArray(x) = Asc(x)
Next

Dim strIcon As String
strIcon = "SLimage"
Dim varTemp As Variant
varTemp = bArray 'Space(32754) '32256)


strFilePath = "C:\TestProp.txt" 'GetTempDir & strIcon & ".ico"

Set db = CurrentDb
Set docForm = db.Containers("Forms").Documents(Me.name)
Set prop = docForm.CreateProperty(strIcon, dbBinary, varTemp, False)
docForm.Properties.Append prop
docForm.Properties.Refresh

Set db = Nothing
Set docForm = Nothing
Set prop = Nothing
Exit Function



On Error Resume Next
'lngDataLength = LenB(docForm.Properties(strIcon).Value)
lngDataLength = LenB(prop.Value)

On Error GoTo Err_Handler

'make sure there is binary data in the prop (or the prop itself exists)
If Not (lngDataLength > 0) Then GoTo Exit_Here

'prepare buffer
'abytFileData = StrConv(String$(lngDataLength, vbNullChar), vbFromUnicode)
'get binary data

ReDim abytFileData(1 To lngDataLength)
'abytFileData = docForm.Properties(strIcon).Value
abytFileData = prop.Value


'remove any existing destination file.
intFile = FreeFile
Open strFilePath For Output As intFile
Close intFile

'open the destination file.
Open strFilePath For Binary Access Write Lock Write As intFile

'write the file
Put #intFile, , abytFileData()

'make sure the file is there
If Len(Dir$(strFilePath)) > 0 Then _
WriteIconFile = strFilePath

Exit_Here:
On Error Resume Next
Set docForm = Nothing
Set db = Nothing
Set prop = Nothing
Close intFile
Exit Function

Err_Handler:
Resume Exit_Here

End Function



Private Function ReadIconFile() As String
'reads a binary property of the form and writes it as an icon file
'to temp directory. Returns path to the file.
On Error GoTo Err_Handler
Dim intFile As Integer
Dim abytFileData() As Byte
Dim strFilePath As String
Dim lngDataLength As Long
Dim db As DAO.Database
Dim docForm As DAO.Document
Dim prop As Property
Dim bArray(1 To 65500) As Byte
Dim x As Long

Dim strIcon As String
strIcon = "SLimage"

Dim varTemp As Variant

strFilePath = "C:\TestProp.txt" 'GetTempDir & strIcon & ".ico"

Set db = CurrentDb
Set docForm = db.Containers("Forms").Documents(Me.name)
'Set prop = docForm.CreateProperty(strIcon, dbBinary, varTemp, False)

Set prop = docForm.Properties(strIcon) '.Value

'Set db = Nothing
'Set docForm = Nothing
'Set prop = Nothing
'Exit Function



On Error Resume Next
'lngDataLength = LenB(docForm.Properties(strIcon).Value)
lngDataLength = LenB(prop.Value)

On Error GoTo Err_Handler

'make sure there is binary data in the prop (or the prop itself exists)
If Not (lngDataLength > 0) Then GoTo Exit_Here

'prepare buffer
'abytFileData = StrConv(String$(lngDataLength, vbNullChar), vbFromUnicode)
'get binary data

ReDim abytFileData(1 To lngDataLength)
'abytFileData = docForm.Properties(strIcon).Value
abytFileData = prop.Value


'remove any existing destination file.
intFile = FreeFile
Open strFilePath For Output As intFile
Close intFile


intFile = FreeFile

'open the destination file.
Open strFilePath For Binary Access Write Lock Write As intFile

'write the file
Put #intFile, , abytFileData()

'make sure the file is there
If Len(Dir$(strFilePath)) > 0 Then _
ReadIconFile = strFilePath

Exit_Here:
On Error Resume Next
Set prop = Nothing
Set docForm = Nothing
Set db = Nothing

Close intFile
Exit Function

Err_Handler:
Resume Exit_Here

End Function





 

 

 
 
 

May 23, 2004 Product Update
 
 
Rich Text ActiveX control. Version 1.8

Click Here!

 

Mar 15, 2005 Product Update
 
MouseHook  Replaces the MouseWheel DLL subclassing solution. Turns On/Off the MouseWheel with one line of code. No DLL registration required. Now supports Logitech mice!

Click Here! 

 

 

 
Home ] Up ] Next ] 
Stephen Lebans Copyright 2009

Last Modified : 09/11/09 12:03 AM