I am relatively new to using SQL but I have gotten several insert and update queries working quite well. I cannot however seem to figure out how to use the SELECT SQL to get a value from a table.
Here is my code that is under the "Click" action of a button:
Dim db As DAO.Database
Dim strSQL As String
Set db = CurrentDb
strSQL = "SELECT Count([username])" & _
"AS [Number]" & _
"FROM Userlog" & _
"WHERE (((IsNull([exit]))=True));"
Me.fltext = strSQL 'this is my text box
I have tried using a msgbox and a text box to see the value but all I see is the SQL statement. This works if I use the query builder and test the statement.
I am using this to determine the amount of users currently logged into my db. It is querying my table userlog which has login/logout date/time/user recorded.
My end goal is to use this to determine if there is more than one user in the db so I can do a backup and therefor the value will be used as part of a control.
so my question...
Why does the query builder give me a number of users... yet when I try to set the value of a msgbox of text box to strSQL all I see is the SQL statement? I need to pull the number generated by the count() function.
Here is my code that is under the "Click" action of a button:
Dim db As DAO.Database
Dim strSQL As String
Set db = CurrentDb
strSQL = "SELECT Count([username])" & _
"AS [Number]" & _
"FROM Userlog" & _
"WHERE (((IsNull([exit]))=True));"
Me.fltext = strSQL 'this is my text box
I have tried using a msgbox and a text box to see the value but all I see is the SQL statement. This works if I use the query builder and test the statement.
I am using this to determine the amount of users currently logged into my db. It is querying my table userlog which has login/logout date/time/user recorded.
My end goal is to use this to determine if there is more than one user in the db so I can do a backup and therefor the value will be used as part of a control.
so my question...
Why does the query builder give me a number of users... yet when I try to set the value of a msgbox of text box to strSQL all I see is the SQL statement? I need to pull the number generated by the count() function.