30/12/2009, 14:52
sayıların sıralı olmasını istediğiniz metin Kutusunun denetim Kaynağına
yazın ve aşağıdaki kodları vb'ya ekleyin
Kod:
=RowNum([Form])
Kod:
Public Function RowNum(frm As Form) As Variant
On Error GoTo Err_RowNum
With frm.RecordsetClone
.Bookmark = frm.Bookmark
RowNum = .AbsolutePosition + 1
End With
Exit_RowNum:
Exit Function
Err_RowNum:
If Err.Number <> 3021& Then
Debug.Print "RowNum() error " & Err.Number & " - " & Err.Description
End If
RowNum = Null
Resume Exit_RowNum
End Function
Function GetLineNumberForm(f As Form)
Dim rs As Recordset
Dim frmMain As Form
Dim frmCur As Form
Dim strName As String
Dim IsItSubForm As Boolean
Dim strFName As String
On Error Resume Next
strFName = f.Parent.Name
IsItSubForm = (Err = 0)
On Error GoTo Err_GetLineNumber
If IsItSubForm Then
Set frmMain = f.Parent.Form
strName = f.Name
Set frmCur = frmMain(strName).Form
Set rs = frmCur.RecordsetClone
Else
Set rs = f.RecordsetClone
Set frmCur = f
End If
rs.Bookmark = frmCur.Bookmark
GetLineNumberForm = rs.AbsolutePosition + 1
Bye_GetLineNumber:
Set rs = Nothing
Set frmMain = Nothing
Set frmCur = Nothing
Exit Function
Err_GetLineNumber:
Resume Bye_GetLineNumber
End Function
Function Serialize(qryname As String, keyname As String, keyvalue) As Long
Dim dbs As Database
Dim rs As Recordset
Set dbs = CurrentDb
On Error GoTo Err_Serialize
Set rs = dbs.OpenRecordset(qryname, dbOpenDynaset, dbReadOnly)
On Error GoTo Err_Serialize
Select Case rs.Fields(keyname).Type
Case DB_INTEGER, DB_LONG, DB_CURRENCY, DB_SINGLE, _
DB_DOUBLE, DB_BYTE
rs.FindFirst "[" & keyname & "] = " & keyvalue
Case DB_DATE
rs.FindFirst "[" & keyname & "] = #" & keyvalue & "#"
Case DB_TEXT
rs.FindFirst "[" & keyname & "] = '" & keyvalue & "'"
Case Else
MsgBox "ERROR: Invalid key field data type!"
End Select
Serialize = Nz(rs.AbsolutePosition, 0) + 1
Err_Serialize:
rs.Close
dbs.Close
Set rs = Nothing
Set dbs = Nothing
End Function