Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

how to store result from "select count(*) ..." in a vba-string

how to store result from "select count(*) ..." in a vba-string

how to store result from "select count(*) ..." in a vba-string

hi there!

here is my problem:

i'd like to store the result of a sql-select (like: 'select count(*) from [table]') in a string.
i am using MS Access97 with VBA!

i just don't get this DAO-stuff...

thanx! :)


RE: how to store result from "select count(*) ..." in a vba-string

Dim myResults as string

myResults = SELECT Count([tablename].[fieldname]) FROM tablename;

However you can't do a count using an *.


RE: how to store result from "select count(*) ..." in a vba-string

to padinka:

thank you for your help!!

i just have thrown this 'select count(*)' - idea away.

i am using a 'normal' select and save the result to a recordset and count it's entries...

' SELECT-string for Recordset

If subject <> "'*'" Then
strSELECT = "SELECT * FROM supportcall WHERE             supportcall.subject = " & _
subject & " AND supportcall.calldate = #" & mydate & "#;"
strSELECT = "SELECT * FROM supportcall WHERE supportcall.calldate = #" & mydate & "#;"
End If
' build Recordset
Set rstCallCount = CurrentDb.OpenRecordset(strSELECT)
If Not rstCallCount.EOF Then
Do While Not (rstCallCount.EOF)
i = i + 1
Select Case rstCallCount.Fields(2).Value
Case Is = "< 5 min"
 less5min = less5min + 1
Case Is = "~ 1 hour"
 about1hour = about1hour + 1
Case Is = "~ 1 day"
 about1day = about1day + 1
Case Is = "> 1 day"
 greater1day = greater1day + 1
End Select
Select Case rstCallCount.Fields(3).Value
Case Is = "none"
 vit_none = vit_none + 1
Case Is = "Front-Office"
 vit_front = vit_front + 1
Case Is = "Back-Office"
 vit_back = vit_back + 1
Case Is = "Kondor+"
 vit_kondor = vit_kondor + 1
End Select

End If

this seems to work fine.
but anyway thank you!



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close