472,145 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

Highlight a line in a continuous form (& FindFirst)

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.
Aug 8 '07 #1
3 3155
JKing
1,206 Expert 1GB
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.
Aug 8 '07 #2
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!
Aug 9 '07 #3
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"?
Aug 10 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Prakash Wadhwani | last post: by
2 posts views Thread by Steve K | last post: by
3 posts views Thread by eighthman11 | last post: by
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.