Result in message box

  • Thread starter Thread starter naveen prasad
  • Start date Start date
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
 
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.
 
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"
 
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".
 
Back
Top