getResultFromSQL(String) As Variant

/ Published in: Visual Basic
Save to your folder(s)

This method runs a SQL query and returns the first result (the query is expected to return exactly one record and one field).

Copy this code and paste it in your HTML
  1. Private Function getResultFromSQL(sql As String) As Variant
  2. Dim recordset As recordset
  4. Set recordset = CurrentDb.OpenRecordset(sql)
  6. If (Not recordset.EOF) _
  7. And (Not recordset.BOF) Then
  8. recordset.MoveFirst
  9. getResultFromSQL = recordset(0)
  11. Set recordset = Nothing
  12. Exit Function
  13. End If
  15. Set recordset = Nothing
  16. getResultFromSQL = Nothing
  17. End Function

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.