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
2009-12-22 21:25:52
i want something like msgbox MyQuery
I__
2009-12-22 21:53:50
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
2009-12-22 22:15:02
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__
2009-12-22 22:16:38
etc.. etc.. that is myquery
I__
2009-12-22 22:17:08
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
2009-12-22 23:10:10
cool can you code that up
I__
2009-12-24 22:15:51
+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
2009-12-22 21:50:30