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

Help! A complicate VBA inquiry, difficult in STRING treatment

Discussion in 'Information Technology' started by Martin \(Martin Lee\), Jul 28, 2006.

  1. Martin \(Martin Lee\)

    Martin \(Martin Lee\)
    Expand Collapse
    Guest

    The following VBA is wrong, how to make it correct :

    [Forms]![mydatafileform].Filter = "bstatus like '" & Me![Combo156] & "'
    AND "" & Me![Combo158] &"" Between " & _
    Format(Me.Text149, "\#yyyy-mm-dd\#") & " AND " & _
    Format(Me.Text151, "\#yyyy-mm-dd\#")

    My explain:

    this VBA inquiry have 3 criterias:
    1. bstatus should = COMBO156

    2. For example, if combo158's content is APPLICATION DATE , then
    criteria is: [application date] is between 2006-01-20 to 2006-02-20 ( these
    two days is for example to make it easier for you to understand)
    if combo156's content is FININSHED DATE, then criteria
    is : [FINISHED DATE] is between 2006-01-20 to 2006-02-20
    REMARK: [application date] and [FINISHED DATE] are both field names.

    3. the upper "2006-01-20" to "2006-02-20" is input by the user, in
    TEXT149 and TEXT151.
     
  2. Loading...


  3. ChrisJ

    ChrisJ
    Expand Collapse
    Guest

    Here's a hint on how to debug this kind of problem

    instead of writing ...

    [Forms]![mydatafileform].Filter = "bstatus like '" & Me![Combo156] & "'
    AND "" & Me![Combo158] &"" Between " & _
    Format(Me.Text149, "\#yyyy-mm-dd\#") & " AND " & _
    Format(Me.Text151, "\#yyyy-mm-dd\#")

    write
    dim sSql as string
    sSql = "bstatus like '" & Me![Combo156] & "'
    AND "" & Me![Combo158] &"" Between " & _
    Format(Me.Text149, "\#yyyy-mm-dd\#") & " AND " & _
    Format(Me.Text151, "\#yyyy-mm-dd\#")

    Then put a break point on this statement.
    when the execution stops on the breakpoint
    open an "Immediate" window and type
    ?sSql
    You will probably find that you need some [] brackets




    "Martin (Martin Lee)" wrote:

    > The following VBA is wrong, how to make it correct :
    >
    > [Forms]![mydatafileform].Filter = "bstatus like '" & Me![Combo156] & "'
    > AND "" & Me![Combo158] &"" Between " & _
    > Format(Me.Text149, "\#yyyy-mm-dd\#") & " AND " & _
    > Format(Me.Text151, "\#yyyy-mm-dd\#")
    >
    > My explain:
    >
    > this VBA inquiry have 3 criterias:
    > 1. bstatus should = COMBO156
    >
    > 2. For example, if combo158's content is APPLICATION DATE , then
    > criteria is: [application date] is between 2006-01-20 to 2006-02-20 ( these
    > two days is for example to make it easier for you to understand)
    > if combo156's content is FININSHED DATE, then criteria
    > is : [FINISHED DATE] is between 2006-01-20 to 2006-02-20
    > REMARK: [application date] and [FINISHED DATE] are both field names.
    >
    > 3. the upper "2006-01-20" to "2006-02-20" is input by the user, in
    > TEXT149 and TEXT151.
    >
    >
    >
     
  4. Martin \(Martin Lee\)

    Martin \(Martin Lee\)
    Expand Collapse
    Guest

    You are my hero! Thank you very much!

    Martin Lee

    "ChrisJ" <ChrisJ@discussions.microsoft.com> дÈëÏûÏ¢ÐÂÎÅ:BEFD1175-9452-4BF7-84C3-8C149D9A895C@microsoft.com...
    > Here's a hint on how to debug this kind of problem
    >
    > instead of writing ...
    >
    > [Forms]![mydatafileform].Filter = "bstatus like '" & Me![Combo156] & "'
    > AND "" & Me![Combo158] &"" Between " & _
    > Format(Me.Text149, "\#yyyy-mm-dd\#") & " AND " & _
    > Format(Me.Text151, "\#yyyy-mm-dd\#")
    >
    > write
    > dim sSql as string
    > sSql = "bstatus like '" & Me![Combo156] & "'
    > AND "" & Me![Combo158] &"" Between " & _
    > Format(Me.Text149, "\#yyyy-mm-dd\#") & " AND " & _
    > Format(Me.Text151, "\#yyyy-mm-dd\#")
    >
    > Then put a break point on this statement.
    > when the execution stops on the breakpoint
    > open an "Immediate" window and type
    > ?sSql
    > You will probably find that you need some [] brackets
    >
    >
    >
    >
    > "Martin (Martin Lee)" wrote:
    >
    >> The following VBA is wrong, how to make it correct :
    >>
    >> [Forms]![mydatafileform].Filter = "bstatus like '" & Me![Combo156] &
    >> "'
    >> AND "" & Me![Combo158] &"" Between " & _
    >> Format(Me.Text149, "\#yyyy-mm-dd\#") & " AND " & _
    >> Format(Me.Text151, "\#yyyy-mm-dd\#")
    >>
    >> My explain:
    >>
    >> this VBA inquiry have 3 criterias:
    >> 1. bstatus should = COMBO156
    >>
    >> 2. For example, if combo158's content is APPLICATION DATE , then
    >> criteria is: [application date] is between 2006-01-20 to 2006-02-20 (
    >> these
    >> two days is for example to make it easier for you to understand)
    >> if combo156's content is FININSHED DATE, then
    >> criteria
    >> is : [FINISHED DATE] is between 2006-01-20 to 2006-02-20
    >> REMARK: [application date] and [FINISHED DATE] are both field names.
    >>
    >> 3. the upper "2006-01-20" to "2006-02-20" is input by the user, in
    >> TEXT149 and TEXT151.
    >>
    >>
    >>
     
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