Results 1 to 2 of 2

Thread: Message box

  1. #1
    Join Date
    Oct 2005
    Posts
    23

    Unanswered: Message box

    Can I create a message from sql ? I want to create a message saying Attention ! I have the following sql:


    StrSQL = " SELECT qryCrosstab.ProductID, Sum(qryCrosstab.[-1]) AS [SumOf-1], Sum(qryCrosstab.[0]) AS SumOf0, [SumOf-1]-[SumOf0] AS Saldo, products.items6 AS stock" & _
    " FROM qryCrosstab INNER JOIN products ON qryCrosstab.ProductID = products.Productid " & _
    " WHERE (((qryCrosstab.afid) = = " & InOffice & "))" & _
    " GROUP BY qryCrosstab.ProductID, products.items= " & InItems & ";"
    CurrentDb.Execute StrSQL

    End Function


    My question is, can I create a message with the message box, when the saldo is not equal to the stock ?

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    I have no idea, I have never tried to put a MsgBox() inside an SQL statement before. My guess would be "no".

    You're probably going to need to take different actions depending on whether Saldo = Stock or not, so it makes more sense to do this with VBA rather than trying to put it inside an SQL statement anyway.

    Since the SQL is inside a function, you can fetch the value of Saldo and Stock and use and then compare them, produce your message and take necessary action.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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