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!

Linenumber X . Y 1

Status
Not open for further replies.

vdzr

Technical User
Mar 6, 2003
42
DE
Is it possible to put a total 'Y' in the recordlinenumbering

I have a working functioncode but don't know how to put the total(lines) in it.


Function GetLijnNr(F As Form, SleutelNaam As String, LnStWaarde)
Dim RS As Recordset
Dim CountLines
'Dim maxcount As Integer

On Error GoTo Err_GetLijnNr

Set RS = F.RecordsetClone

' Zoek huidig record.
Select Case RS.Fields(SleutelNaam).Type
' Zoek waardeveldtypesleutel?
Case DB_INTEGER, DB_LONG, DB_CURRENCY, DB_SINGLE, _
DB_DOUBLE, DB_BYTE
RS.FindFirst "[" & SleutelNaam & "] = " & LnStWaarde
' Zoek met datumveldwaardetypesleutel?
Case DB_DATE
RS.FindFirst "[" & SleutelNaam & "] = #" & LnStWaarde & "#"
' Zoek met tekstdatatypesleutel?
Case DB_TEXT
RS.FindFirst "[" & SleutelNaam & "] = '" & LnStWaarde & "'"
Case Else
MsgBox "ERROR: Invalid key field data type!"
Exit Function
End Select

' Loop achteruit, lijnen tellen.
Do Until RS.BOF
--> CountLines = CountLines + 1 ' & " . " & maxcounter
RS.MovePrevious
Loop

Bye_GetLijnNr:
' Resultaat terug geven.
GetLijnNr = CountLines

Exit Function

Err_GetLijnNr:
CountLines = 0
Resume Bye_GetLijnNr

End Function

The control source of a unbound linenr. textbox --> =GetLijnNr([Form];"PrimIDTstblwoningen";[PrimIDTstblwoningen])
 
Yes the counter is now good but in the new record there is always a . Y (a peace of the counter) to see.

When I placed the recordcount at the place of the arrow (green text) it was giving the result :
1.4
0
0
0
.4


When placed in :
Bye_GetLijnNr:
' Resultaat terug geven.
GetLijnNr = CountLines & " . " & RS.RecordCount
Exit Function

The result was good but for the new record still a .4 shows??
 
Where do I have to put 'if me.newrecord'?

 
Something like:

Code:
Dim RecCount

If f.NewRecord = True Then
   RecCount=""
Else
   RecCount= "." & rs.RecordCount
End If

GetLijnNr = CountLines & RecCount
 
OK now it's working

I still didn't know where to put the code

but after some trial it works

if then else in the do while loop and then everything was ok

thanks
big star
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top