Need Result show in Message Box

N

naveen prasad

Hi all....
Need your help badly....

example....

table t1 fields are name,place, designation,company

query q1 select count(designation) from t1;

query when executed result is 15.

Form f1 has command button cmd1

when clicked it will execute the query but result is comming in spread sheet
window.

what i need when clicked it should show result in message box...

pls help me how can i do it
 
J

John W. Vinson

Hi all....
Need your help badly....

example....

table t1 fields are name,place, designation,company

query q1 select count(designation) from t1;

query when executed result is 15.

Form f1 has command button cmd1

when clicked it will execute the query but result is comming in spread sheet
window.

what i need when clicked it should show result in message box...

pls help me how can i do it

The Count function counts records. What is in [designation]? Are you trying to
count the number of distinct designation values in the table (you have no
criteria in the query). Your query will in fact count the number of records in
t1 which have non-NULL values in designation.

And a Msgbox is a *very* user unfriendly manner of presenting data.

What real-life problem are you attempting to solve? What should you be
counting? What will the user do with the 15 when she sees it?
 
P

PieterLinden via AccessMonster.com

naveen said:
Hi all....
Need your help badly....
example....
table t1 fields are name,place, designation,company
query q1 select count(designation) from t1;
query when executed result is 15.
Form f1 has command button cmd1
when clicked it will execute the query but result is comming in spread sheet
window.
what i need when clicked it should show result in message box...
pls help me how can i do it

If all you want to do is get the number of records

Function GetRecordCount() as Long
dim qdf as querydef
dim rs as recordset

set qdf = DBEngine(0)(0).Querydefs("q1")
set rs = qdf.OpenRecordset
GetRecordCount = rs.RecordCount

rs.close
set rs=nothing
set qdf = nothing
End Function

MsgBox "Your query contains " & GetRecordCount() & " records.", vbokonly
 
D

Duane Hookom

I think this is the third message I have seen that you have asked the same
question. Can't you ask once and then if you don't understand, reply back in
the same thread?

Duane Hookom
MS Access MVP
 

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