Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004
    Posts
    4

    Question Unanswered: Getting MsgBox to display data from query

    G'day,

    I'm a bit of a novice at this but what is the easiest solution in getting the Msgbox (running in a Macro) to display specific data from a query??..

    eg. I have a query that is taking the top record from a table (say for example, it is taking the AutonumberID, date and a count field) and I want to be able to display the value from that extracted count field in the query, as part of my Msgbox display.


    Any easy/quick solutions before I start beating my head against the wall...

    Thanks

  2. #2
    Join Date
    Feb 2004
    Posts
    533
    Code:
     
    
    Sub GetQueryValue()
    
    Set db = CurrentDb
    
    Set rst = db.OpenRecordset("qryCountRecs")
    If Not rst.RecordCount = 0 Then
    rst.MoveFirst
    Else
        MsgBox "Your query is Empty"
    Exit Sub
    End If
    
    strRecVal = rst.Fields(0)
    
    MsgBox "There are '" & strRecVal & "' Records from your query."
    
    rst.Close
    End Sub
    .
    ~

    Bill

  3. #3
    Join Date
    Oct 2004
    Posts
    4
    Thank you... Works a treat...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •