Toolbar Control Usage
Hello,
I Just discovered how to use the toolbar control, and in googling the net I found that there was little to no help. In order to save other people time here is briefly how I got the toolbar control to work.
- On a form with a Datasheet subform go find the toolbar control:
You can refer to this website on how to do the toolbar form
http://www.vbexplorer.com/VBExplorer/vb_feature/july2000/july2000.asp
- You will need to make some global form variables, or use values in your database to hold the selHeight and SelTop:
Option Compare Database
Dim intTop As Integer
Dim intHeight As Integer
- In the "Private Sub Toolbar_MouseMove" event place code to capture the SelHeight, and SelTop property of your subform:
Private Sub Toolbar_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Long, ByVal y As Long)
If intTop <> Me.cfmDatasheet.Form.SelTop Then
intHeight = Me.cfmDatasheet.Form.SelHeight
intTop = Me.cfmDatasheet.Form.SelTop
End If
End Sub
The MouseMove event occurs a million times a second so long as your mouse is hovering over the toolbar, so you want to make sure to make a provision for capturing it the first instant your mouse is over the button, hence the if statement comparing the variable.
- Now you need to put something for the event that handles the clicky of da button.
Private Sub Toolbar_ButtonClick(ByVal Button As Object)
Select Case Button.Index
Case 1
MsgBox "Top of selection is " & intTop
MsgBox "Height of selection is " & intHeight
intTop = -1
intHeight = -1
End Select
End Sub
Note that after whatever it is that you are doing (in the place of the messagebox) you have to set the top and length to something else so that the next time you make a selection the values are reset.
The other thing you may want to do is make a provision for the fact that if the user just goes straight for the button the height will be 0 if they have yet to select something.