Connecting Tech Pros Worldwide Forums | Help | Site Map

HELP with VBA Code for Unmatched Query

sal cifone
Guest
 
Posts: n/a
#1: Nov 12 '05
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
"Commissions" 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.OpenRecordset("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
Guest
 
Posts: n/a
#2: Nov 12 '05

re: HELP with VBA Code for Unmatched Query


salvatore_cifone@adp.com (sal cifone) wrote in message news:<4b3ef4ee.0311071346.1ac87a73@posting.google. 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
> "Commissions" 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).
Sal Cifone
Guest
 
Posts: n/a
#3: Nov 12 '05

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!
Closed Thread