By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,366 Members | 1,366 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,366 IT Pros & Developers. It's quick & easy.

HELP with VBA Code for Unmatched Query

P: n/a
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
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
sa**************@adp.com (sal cifone) wrote in message news:<4b**************************@posting.google. com>...
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?


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).
Nov 12 '05 #2

P: n/a
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!
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.