HELP with VBA Code for Unmatched Query

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sal cifone

    #1

    HELP with VBA Code for Unmatched Query

    Hello,

    I am trying to use access vba instead of running an unmatched query.
    I want to compare two tables and if there is a new sales office in
    "Commission s" table that is not in the "Conversion " table I want to
    know which region.


    I'm lost. Can someone help? Here is my code.

    Sub now()

    Dim CurDb As Database
    Dim rst As Recordset


    Set CurDb = CurrentDb

    Set rst = CurDb.OpenRecor dset("SELECT Commissions.[SALES OFFICE]"
    & _
    "FROM Commissions LEFT JOIN [Sales Office Conversion] ON
    Commissions.[SALES OFFICE] = [Sales Office Conversion].Sales_Office" &
    _
    "GROUP BY Commissions.[SALES OFFICE], [Sales Office
    Conversion].Sales_Office" & _
    "HAVING ((([Sales Office Conversion].Sales_Office) Is
    Null))" & _
    "ORDER BY Commissions.[SALES OFFICE]")

    With rst
    MsgBox Commissions.[SALES OFFICE]
    End With

    rst.Close
    Set rst = Nothing
    End Sub



    Sal
  • Pieter Linden

    #2
    Re: HELP with VBA Code for Unmatched Query

    salvatore_cifon e@adp.com (sal cifone) wrote in message news:<4b3ef4ee. 0311071346.1ac8 7a73@posting.go ogle.com>...[color=blue]
    > Hello,
    >
    > I am trying to use access vba instead of running an unmatched query.
    > I want to compare two tables and if there is a new sales office in
    > "Commission s" table that is not in the "Conversion " table I want to
    > know which region.
    >
    >
    > I'm lost. Can someone help?[/color]

    Sal,
    why not just leave the unmatched query and pass parameters to it?
    Then you could just open the recordset off the querydef and be done
    with it. MUCH easier than doing it with code. The only difference is
    that you'd open your recordset off the query (after passing parameters
    to it). Then if you open a recordset with the region field in it, you
    can just return that/those values if there are any. (use a snapshot
    recordset and you can do a reliable recordcount).

    Comment

    • Sal Cifone

      #3
      Re: HELP with VBA Code for Unmatched Query

      Thanks for the reply,

      I am a newbie when it comes to Access VB. I do not know how to do what
      you suggest.


      Sal



      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      Working...