add a where statement on my code

lovedieer

Registered User.
Local time
Today, 11:34
Joined
Nov 4, 2009
Messages
28
I am new for VBA code.
I copied a cascade listing code from internet and revise to fit my program. If I select a region, then the Agency under that region will show up. I still need an extra where statement : Note = "SC". I tried several time and always get error, can somebody help me add the statement?

Many Many thanks.


Code:
 Private Sub Region_AfterUpdate()
    On Error Resume Next
    SCAgency.RowSource = "Select tblProvAgency.Agency " & _
        "FROM tblProvAgency " & _
        "WHERE tblProvAgency.Region = '" & Region.Value & "' " & _
         "ORDER BY tblProvAgency.Id;"
End Sub
 
Code:
    SCAgency.RowSource = "Select tblProvAgency.Agency " & _
        "FROM tblProvAgency " & _
        "WHERE tblProvAgency.Region = '" & Region.Value & "' [COLOR="Red"][B]AND [Note]='SC' [/B][/COLOR]" & _
         "ORDER BY tblProvAgency.Id;"
 
Thanks. It's work.
 
I got another question (please forgive my poor knowldge on coding).

After the region is updated, only Agency was cascaded in my code. If I also want to cascade several other information which have the same level as agency. How do I modify the code
Thanks again.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom