Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

VBA--click a button to open a TABLE and only show conditioned records ?

Discussion in 'Information Technology' started by Martin, Oct 29, 2005.

  1. Martin

    Martin
    Expand Collapse
    Guest

    In a FORM, I want to create a button, when I click this button, the Access
    will open TABLE "Customer Inf", with the condition that field "customer
    name"="Martin Lee". Also, I want,below the selected "Martin Lee" records, it
    has a blank line for which the users to enter a new record here.

    How should the VBA code should be ?


    BTW, if it is a QUERY (instead of a FORM), how should the VBA code be, to
    filter up "customer name"="Martin Lee"?


    Thanks!


    Martin
     
  2. Loading...

    Similar Threads Forum Date
    Should SPN Keep the 'Like' Button? SPN Poll Hard Talk May 17, 2013

  3. Dirk Goldgar

    Dirk Goldgar
    Expand Collapse
    Guest

    "Martin" <lajitong888@21cn.com> wrote in message
    news:%23uqhgS92FHA.1476@TK2MSFTNGP10.phx.gbl
    > In a FORM, I want to create a button, when I click this button, the
    > Access will open TABLE "Customer Inf", with the condition that field
    > "customer name"="Martin Lee". Also, I want,below the selected "Martin
    > Lee" records, it has a blank line for which the users to enter a new
    > record here.
    >
    > How should the VBA code should be ?


    I don't recommend letting your users work directly in the tables. For
    one thing, you have much less control. Why not create a continuous form
    (or even a datasheet form) bound to this table; then you can open it
    and supply the where-condition at the same time via the DoCmd.OpenForm
    method.

    If you insist on opening the table directly, there's no way to filter it
    in the same statement that opens it. However, you can filter it in the
    very next statement, like this:

    Dim strCustomerWanted As String

    strCustomerWanted = "Martin Lee"

    Docmd.OpenTable "Customer Inf"
    DoCmd.ApplyFilter , "[customer name]=" & _
    Chr(34) & strCustomerWanted & Chr(34)

    Note the comma that immediately follows the name of the ApplyFilter
    method. That's critical, because it distinguishes the optional
    "FilterName" argument (which we're not using) from the "WhereCondition"
    argument (which we are using).

    > BTW, if it is a QUERY (instead of a FORM), how should the VBA code
    > be, to filter up "customer name"="Martin Lee"?


    I'm not sure I understand this question.

    --
    Dirk Goldgar, MS Access MVP
    www.datagnostics.com

    (please reply to the newsgroup)
     
  4. Martin

    Martin
    Expand Collapse
    Guest

    Thanks, and I have several question base on your answer. New posted.
    "Dirk Goldgar" <dg@NOdataSPAMgnostics.com> дÈëÏûÏ¢ÐÂÎÅ:e5C1XI$2FHA.1276@TK2MSFTNGP09.phx.gbl...
    > "Martin" <lajitong888@21cn.com> wrote in message
    > news:%23uqhgS92FHA.1476@TK2MSFTNGP10.phx.gbl
    >> In a FORM, I want to create a button, when I click this button, the
    >> Access will open TABLE "Customer Inf", with the condition that field
    >> "customer name"="Martin Lee". Also, I want,below the selected "Martin
    >> Lee" records, it has a blank line for which the users to enter a new
    >> record here.
    >>
    >> How should the VBA code should be ?

    >
    > I don't recommend letting your users work directly in the tables. For
    > one thing, you have much less control. Why not create a continuous form
    > (or even a datasheet form) bound to this table; then you can open it
    > and supply the where-condition at the same time via the DoCmd.OpenForm
    > method.
    >
    > If you insist on opening the table directly, there's no way to filter it
    > in the same statement that opens it. However, you can filter it in the
    > very next statement, like this:
    >
    > Dim strCustomerWanted As String
    >
    > strCustomerWanted = "Martin Lee"
    >
    > Docmd.OpenTable "Customer Inf"
    > DoCmd.ApplyFilter , "[customer name]=" & _
    > Chr(34) & strCustomerWanted & Chr(34)
    >
    > Note the comma that immediately follows the name of the ApplyFilter
    > method. That's critical, because it distinguishes the optional
    > "FilterName" argument (which we're not using) from the "WhereCondition"
    > argument (which we are using).
    >
    >> BTW, if it is a QUERY (instead of a FORM), how should the VBA code
    >> be, to filter up "customer name"="Martin Lee"?

    >
    > I'm not sure I understand this question.
    >
    > --
    > Dirk Goldgar, MS Access MVP
    > www.datagnostics.com
    >
    > (please reply to the newsgroup)
    >
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page