example of a function

and example of sql query in  visual basic

**********************************

Option Compare Database
--------------------------------------------------------

Function fctviewresultSessId() As Integer
'the query opens the session id table
'only the highest value entered in the sessionid table is shown here
'this value will be used for the future operations
Dim RecSrcFrmSessIdLoadSql As String

RecSrcFrmSessIdLoadSql = "SELECT TOP 1 [tblSessionId].[SessionId]" & _
"FROM [tblSessionId]" & _
"ORDER BY [tblSessionId].[SessionId] DESC;"
Forms!frmSessionID.RecordSource = RecSrcFrmSessIdLoadSql

End Function

--------------------------------------------------------

'here the form will show the last id pasted
Private Sub Form_Load()
fctviewresultSessId
DoCmd.Requery
End Sub