Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use Mouse to select records on continuous form 1

Status
Not open for further replies.

GPM4663

Technical User
Aug 9, 2001
165
GB
Hi Everyone,
I posted this on the forms forum but I think it might be better suited here. I would like to use the mousemove event to move to that record on a continuous form. The reason being so that the tooltip changes to display informatio about that particular record and not just the record that the cursor is in. Would anyone have any advice?

Thanks in advance,

GPM
 
I played with this, and the following concept works actually pretty well.

The demo uses a continous form in the Northwind DB with a form header.
Code:
Option Compare Database
Option Explicit
Public recordNo As Long


Private Sub Form_Load()
 Me.OrderID.ControlTipText = getText(recordNo)
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Dim strToolTip As String
  If Not getRecord(Y) = recordNo Then
    recordNo = getRecord(Y)
    strToolTip = getText(recordNo)
    Me.txtToolTip = strToolTip
    Me.OrderID.ControlTipText = strToolTip
    Me.ProductID.ControlTipText = strToolTip
  End If
  'Me.txtToolTip = Y
End Sub

Public Function getRecord(ByVal Y As Single) As Long
  Dim htrec As Long
  htrec = Me.Detail.Height
  'Form Header
  Y = Y - Me.Section(1).Height
  getRecord = (Y \ htrec)
 
End Function
Public Function getText(recNo As Long) As String
  On Error GoTo errlable
  Dim rs As Recordset
  Set rs = Me.RecordsetClone
  rs.MoveFirst
  If Not recNo > rs.RecordCount Then
    rs.Move (recNo)
    getText = "Rec No: " & recNo & " ID: " & rs!OrderID & " Name: " & rs!ProductName & " Quantity: " & rs!Quantity & " Unit Price: " & rs!UnitPrice
  End If
  Exit Function
errlable:
  If Err.Number = 3021 Then
    Exit Function
  Else
    MsgBox Err.Number & " " & Err.Description
  End If
End Function
 
Hi MajP,
Thanks for that, I had been playing around with code myself and was trying to do what you have done - your code is a lot neater and slicker. That works a treat, thanks so much for all your help with it, I really appreciate it. Those links are brilliant reading as well.

Thanks again,

GPM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top