tags:

views:

307

answers:

2

how do i feed the result of a query into a msgbox in access?

+1  A: 

I'm not sure I understand, but to set the text displayed in a message box you can call:

MsgBox strYourTextHere

Here's the documentation for the MsgBox function for Access 2007.

Jay Riggs
i want something like msgbox MyQuery
I__
What does MyQuery return? If it's a string it should work (within the limitations imposed by the MsgBox function's 'prompt' parameter - see the documentation in my link).
Jay Riggs
SELECT users.id, users.first, users.last, chavrusas.luser_type AS user_type, chavrusas.id, users.title, users.city, users.state, users.home_phone, users.email FROM Users INNER JOIN chavrusas ON Users.id=chavrusas.luser_id WHERE ((chavrusas.ruser_id)=id_txt and chavrusas.ended=false) AND (chavrusas.luser_type)<>(chavrusas.ruser_type) AND NOT ((chavrusas.luser_type)='teacher' AND (chavrusas.ruser_type)='student') AND NOT ((chavrusas.ruser_type)='teacher' AND (chavrusas.luser_type)='student'); UNION SELECT users.id, users.first, users.last, chavrusas.ruser_type AS user_type, chavrusas.id, users
I__
etc.. etc.. that is myquery
I__
You're getting your data in tabular format. Your best bet for displaying it as shown in the query is a grid or a similar control depending on your requirements. What might work is programmatically looping through the results of your query and building up a formatted string with what you want the user to see and then using this string with the MsgBox function.
Jay Riggs
cool can you code that up
I__
+2  A: 

You may wish to use a recordset.

Dim rs As DAO.Recordset

Set rs=CurrentDB.OpenRecordset("NameOfQuery_Table_Or_SQLString")

If Not rs.EOF Then
   MsgBox "Hi, the first record, first field is " & rs.Fields(0)
End if

You could also use an ADO recordset if you wish to return all the records to a string.

It might be easier to use DLookUp, it all depends on what you want returned and from where.

Remou