By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,165 Members | 853 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,165 IT Pros & Developers. It's quick & easy.

Making Continuous Forms Work Like Datasheets with Adjustable Columns

P: n/a
I've seen a lot of posts asking how to get Datasheet-like
functionality into a Continuous Form. One of the obvious missing
elements is adjustable column widths. I had the same need so I created
the following code:

On a continuous form, in the Form Header section, between two heading
labels, create a box with the height equalling the header height and
the width = 0.1576". Name this box BoxColumn1.
Create two text boxes named LeftColumName and RightColumName
Rename the labels for these text boxes to LeftColumLabel and
RightColumLabel

Add this code to the OnMouseMove event of BoxColumn1:
'START CODE
************************************************** ***************************************
Dim intLeftButton As Integer
Dim ColumOneAdjust as Integer
Dim ColumTwoAdjust as Integer

intLeftButton = Button And acLeftButton
ColumOneAdjust = 60
ColumTwoAdjust = 800

' as you move over the box, the pointer will change to the left-right
size arrows:
Screen.MousePointer = 9

' only if you click the left mouse button will you're over
BoxColumn1 will it size, otherwise just pass over the box:
If intLeftButton 0 Then

'now calculate all the sizes:
If (Me.BoxColumn1.Left + x) - ColumOneAdjust >
Me.LeftColumName.Left + ColumTwoAdjust And Me.BoxColumn1.Left + x <
Me.ContactsType.Left - 1200 Then
Me.BoxColumn1.Left = Me.BoxColumn1.Left + x
Me.BoxColumn1Row.Left = Me.BoxColumn1.Left
Me.LeftColumName.Width = (Me.BoxColumn1.Left -
Me.LeftColumName.Left) - 100
Me.LeftColumLabel.Width = Me.LeftColumName.Width
Me.RightColumName.Width = Me.ContactsType.Left -
(Me.RightColumName.Left + 60)
Me.RightColumName.Left = Me.BoxColumn1.Left + 60
Me.RightColumLabel.Left = Me.RightColumName.Left
Me.RightColumLabel.Width = Me.RightColumName.Width
End If

End If

'END
CODE********************************************** ************************************************** ******

You will have to adjust the values for ColumOneAdjust and
ColumTwoAdjust to limit the left to right adjustment of your columns
based on the width of the columns you need.

Repeat this for all columns you wish to create and adjust in your
continuous form.

I hope this helps,
lq
Nov 16 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.