Connecting Tech Pros Worldwide Forums | Help | Site Map

Highlight a line in a continuous form (& FindFirst)

Member
 
Join Date: Feb 2007
Location: Aylesbury, Bucks, UK
Posts: 62
#1: Aug 8 '07
I am trying to get a continuous form to highlight lines individually (ideally on hover). I have used the following code as recommended by a previous entry on this website. My problems begin in that my Database does not appear to recognise "FindFirst". The sample database I downloaded for help does recognise the script and when I begin to type the drop down gives the prompt for "FindFirst"! Why is it that my MDB does not? The only drop downprompt is "Find"

The code I am trying to work with is:
Expand|Select|Wrap|Line Numbers
  1. Function GetLineNumber()
  2. Dim RS As Recordset
  3. Dim CountLines
  4. Dim F As Form
  5. Dim KeyName As String
  6. Dim KeyValue
  7.  
  8. Set F = Form
  9. KeyName = "productid"
  10. KeyValue = [ProductID]
  11.  
  12.          On Error GoTo Err_GetLineNumber
  13.          Set RS = F.RecordsetClone
  14.          ' Find the current record.
  15.          Select Case RS.Fields(KeyName).Type
  16.             ' Find using numeric data type key value.
  17.             Case DB_INTEGER, DB_LONG, DB_CURRENCY, DB_SINGLE, _
  18.             DB_DOUBLE, DB_BYTE
  19.                RS.FindFirst "[" & KeyName & "] = " & KeyValue
  20.             ' Find using date data type key value.
  21.             Case DB_DATE
  22.                RS.FindFirst "[" & KeyName & "] = #" & KeyValue & "#"
  23.             ' Find using text data type key value.
  24.             Case DB_TEXT
  25.                RS.FindFirst "[" & KeyName & "] = '" & KeyValue & "'"
  26.                RS.F
  27.             Case Else
  28.             MsgBox "ERROR: Invalid key field data type!"
  29.                Exit Function
  30.                End Select
  31.          ' Loop backward, counting the lines.
  32.          Do Until RS.BOF
  33.             CountLines = CountLines + 1
  34.             RS.MovePrevious
  35.             Loop
  36. Bye_GetLineNumber:               ' Return the result.
  37.          GetLineNumber = CountLines
  38.          Exit Function
  39. Err_GetLineNumber:
  40.       CountLines = 0
  41.       Resume Bye_GetLineNumber
  42. End Function
  43.  
Any assistance please.
JKing's Avatar
Moderator
 
Join Date: Jun 2007
Location: Niagara Falls, Ontario
Posts: 557
#2: Aug 8 '07

re: Highlight a line in a continuous form (& FindFirst)


I suppose we should start with the FindFirst issue. Check to make sure you have a reference to the Microsoft DAO 3.6 Object Library (or higher). To do this open the VBA editor and go to Tools > References then scroll through to find and check the library.
Member
 
Join Date: Feb 2007
Location: Aylesbury, Bucks, UK
Posts: 62
#3: Aug 9 '07

re: Highlight a line in a continuous form (& FindFirst)


Quote:

Originally Posted by JKing

I suppose we should start with the FindFirst issue. Check to make sure you have a reference to the Microsoft DAO 3.6 Object Library (or higher). To do this open the VBA editor and go to Tools > References then scroll through to find and check the library.


Have done as suggested and added MS DAO 3.6 as well as Utility.mda but still I can only get "Find" when I start typing and enter a period (.) ie rs. producing a drop down list but sadly no FindFirst only "Find". I am sure there is a simple solution. Your help and knowledge is appreciated!
Member
 
Join Date: Feb 2007
Location: Aylesbury, Bucks, UK
Posts: 62
#4: Aug 10 '07

re: Highlight a line in a continuous form (& FindFirst)


Quote:

Originally Posted by boliches

Have done as suggested and added MS DAO 3.6 as well as Utility.mda but still I can only get "Find" when I start typing and enter a period (.) ie rs. producing a drop down list but sadly no FindFirst only "Find". I am sure there is a simple solution. Your help and knowledge is appreciated!

Have since tried the following which has worked!

Dim rs AS DAO.recordset

This has enabled the FindFirst in the drop down list.

Thanks for the pointer.

Any other ideas on highlighting an individual line in a continuous form ideally on "hover"?
Reply