Results 1 to 3 of 3
  1. #1
    Susy is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    134

    VBA - Query in a Form --> Recordset Select ( SUM (NZ())

    Hi everyone,

    I am having problems with a recordset and don't really now where the problem is.



    Code:
    Private Sub ArtikelAnzahl_AfterUpdate()
    
    Dim zumArtikelStand As Recordset
    Dim newArtikelName As String
    
    newArtikelName = Me.ArtikelName.Value
    
    
    Set zumArtikelStand = CurrentDb.OpenRecordset("SELECT" _
            & "SUM([tblTrans]![ArtikelAnzahl]) AS ArtikelStandA" _
            & "FROM tblArtikel INNER JOIN tblTrans ON tblArtikel.ArtikelName = tblTrans.ArtikelName" _
            & "GROUP BY tblTrans.ArtikelName" _
            & "HAVING (((tblTrans.ArtikelName)='" & newArtikelName & "'))", , dbOpenDynaset)
    
    
    MsgBox "Der ArtikelStand ist: " & zumArtikelStand.Fields("ArtikelStand").Value & " ."
    In the form the name of the field is "ArtikelStand". I have also used
    Code:
    zumArtikelStand.Fields("ArtikelStandA").Value
    but it did not work.

    I really don't know where the problem is.

    Help, please

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Need space after the first quote mark on each continuation line (or before the last quote mark). Without the spaces, the text runs together. Instead of "SELECT SUM" you have "SELECTSUM" and that is meaningless to the query engine.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Susy is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    134
    Hi June7,

    thanks very much for the hint. Now I can continue making sense :-)

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 12-21-2013, 11:03 PM
  2. Multi select rows in recordset
    By Charlie in forum Programming
    Replies: 1
    Last Post: 01-31-2013, 11:49 PM
  3. Form data in SELECT statement recordset
    By nvrwrkn in forum Programming
    Replies: 15
    Last Post: 10-16-2012, 03:57 PM
  4. How to Select second Recordset from first recordset
    By FrustratedAlso in forum Programming
    Replies: 28
    Last Post: 05-10-2012, 05:45 PM
  5. select records in recordset
    By sksriharsha in forum Programming
    Replies: 3
    Last Post: 09-05-2009, 11:40 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums