Result in message box

N

naveen prasad

HI,
this is second time iam posting this ,,kindly help me

a form contains button which runs a query like
select count(field1) from table t1 ... then normally we will get a spread
sheet window containing result in a single cell, let say answer is 85.

now when command button is clicked then a message box should appear
displaying the result 85..

please give coding also if required.....

thanks
 
B

Bob Barrows

naveen said:
HI,
this is second time iam posting this ,,kindly help me
What was wrong with the reply you've already received? Please reply in
your original thread.
 
D

Duane Hookom

Your question is a bit vague however, try code like:

dim strMsg as String
strMsg = "Count: " & DCount("Field1","T1")
MsgBox strMsg, vbOkOnly + vbInformation,"Here is your count"
 
D

Dorian

You need your command button to run an event procudure which you code in VB.

Dim rs as new ADODB.recordset
Dim strSQL as string
Dim intCount as integer
strSQL = "SELECT Count(Field1) As MyCount FROM ......"
rs.open strSQL, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
if not rs.eof
intCount = rs.fields("MyCount").value
else
intCount = 0
end if
rs.close
set rs = nothing
Msgbox "Count is " & intCount,,"Count"


You will need reference for ADO library in Tools--References

-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top