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

Highlight a line in a continuous form (& FindFirst)

P: 62
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
Share this Question
Share on Google+
3 Replies


JKing
Expert 100+
P: 1,206
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

P: 62
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

P: 62
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.