The code I am trying to work with is:
Expand|Select|Wrap|Line Numbers
- Function GetLineNumber()
- Dim RS As Recordset
- Dim CountLines
- Dim F As Form
- Dim KeyName As String
- Dim KeyValue
- Set F = Form
- KeyName = "productid"
- KeyValue = [ProductID]
- On Error GoTo Err_GetLineNumber
- Set RS = F.RecordsetClone
- ' Find the current record.
- Select Case RS.Fields(KeyName).Type
- ' Find using numeric data type key value.
- Case DB_INTEGER, DB_LONG, DB_CURRENCY, DB_SINGLE, _
- DB_DOUBLE, DB_BYTE
- RS.FindFirst "[" & KeyName & "] = " & KeyValue
- ' Find using date data type key value.
- Case DB_DATE
- RS.FindFirst "[" & KeyName & "] = #" & KeyValue & "#"
- ' Find using text data type key value.
- Case DB_TEXT
- RS.FindFirst "[" & KeyName & "] = '" & KeyValue & "'"
- RS.F
- Case Else
- MsgBox "ERROR: Invalid key field data type!"
- Exit Function
- End Select
- ' Loop backward, counting the lines.
- Do Until RS.BOF
- CountLines = CountLines + 1
- RS.MovePrevious
- Loop
- Bye_GetLineNumber: ' Return the result.
- GetLineNumber = CountLines
- Exit Function
- Err_GetLineNumber:
- CountLines = 0
- Resume Bye_GetLineNumber
- End Function