Welcome to SPN

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

Sign Up Now!

Trouble In Paradise: Help with mismatch error

Discussion in 'Information Technology' started by Rambo, Jul 28, 2006.

  1. Rambo

    Rambo
    Expand Collapse
    Guest

    Hi,

    For the following line of code I keep getting a mismatch error and I am
    not sure why
    I am trying to set up a button so that it previews a progress report
    based on two criteria, an employee ID and a date. Currently on_Click
    of my "Preview Report" button I have the following code

    Private Sub cmdPreviewRecord_Click()
    Dim strReportName As String
    Dim strCriteria As String

    str ReportName = "rptProgressReport"
    strCriteria = "[strEmployeeID] = ' " & Me![strEmployeeID] & " ' "
    and
    "[dtmDateofProgress] = ' " & Me![dtmDateofProgress] & " ' "

    DoCmd.OpenReport strReportName, acViewPreview, ,strCriteria

    where [strEmployeeID] is my employee id field and [dtmDateofProgress]
    is my date field

    Can anyone help out?

    Thanks so much.

    Sincerely,
    Rambo
     
  2. Loading...

    Similar Threads Forum Date
    World Toilet Trouble: New Technology and Infrastructures with Dr. Doulaye Kone Breaking News Oct 26, 2013
    USA El Sobrante Gurdwara Committee Troubles Continue Breaking News Jun 25, 2013
    India Troubled Reminder - A memorial for Op Bluestar ‘martyrs’? Breaking News May 12, 2012
    Trouble Understanding This Pauree of Bhai Gurdas Sikh Sikhi Sikhism Sep 5, 2011
    Hinduism Film Screening to Foster Ethnic Unity Stirs Trouble Instead Interfaith Dialogues Jul 22, 2011

  3. Duane Hookom

    Duane Hookom
    Expand Collapse
    Guest

    The "and" must be inside the quotes. Also, you don't want to include extra
    space between your single and double quotes. Assuming EmployeeID is text and
    dtmdateOfProfress is a date, try:

    strCriteria = "[strEmployeeID] = '" & Me![strEmployeeID] & "' and " & _
    "[dtmDateofProgress] = #" & Me![dtmDateofProgress] & "#"

    The above should work well in US locals. You may need to make some changes
    if your date format is not m/d/yyyy.

    --
    Duane Hookom
    MS Access MVP


    "Rambo" <moneyball.wilson@gmail.com> wrote in message
    news:1152289501.936710.183810@p79g2000cwp.googlegroups.com...
    > Hi,
    >
    > For the following line of code I keep getting a mismatch error and I am
    > not sure why
    > I am trying to set up a button so that it previews a progress report
    > based on two criteria, an employee ID and a date. Currently on_Click
    > of my "Preview Report" button I have the following code
    >
    > Private Sub cmdPreviewRecord_Click()
    > Dim strReportName As String
    > Dim strCriteria As String
    >
    > str ReportName = "rptProgressReport"
    > strCriteria = "[strEmployeeID] = ' " & Me![strEmployeeID] & " ' "
    > and
    > "[dtmDateofProgress] = ' " & Me![dtmDateofProgress] & " ' "
    >
    > DoCmd.OpenReport strReportName, acViewPreview, ,strCriteria
    >
    > where [strEmployeeID] is my employee id field and [dtmDateofProgress]
    > is my date field
    >
    > Can anyone help out?
    >
    > Thanks so much.
    >
    > Sincerely,
    > Rambo
    >
     
  4. Phillip Windell

    Phillip Windell
    Expand Collapse
    Guest

    "Rambo" <moneyball.wilson@gmail.com> wrote in message
    news:1152289501.936710.183810@p79g2000cwp.googlegroups.com...
    > Private Sub cmdPreviewRecord_Click()
    > Dim strReportName As String
    > Dim strCriteria As String
    >
    > str ReportName = "rptProgressReport"

    ^--that space should not be there.

    > strCriteria = "[strEmployeeID] = ' " & Me![strEmployeeID] & " ' "


    Isn't EmployeeID a number? If so, it should not have single-quotes around
    it.

    strCriteria = "[strEmployeeID] = " & Me![strEmployeeID]


    > and "[dtmDateofProgress] = ' " & Me![dtmDateofProgress] & " ' "


    dtmDateOfProgress should not have single-quotes around it,..it is a Date
    Type,..not a string. I believe Date Types are supposed to be enclosed
    inside # when in an SQL query. There may be other syntax errors too.

    and "[dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "

    I could be wrong, but maybe it should look like this, or at least something
    similar.

    strCriteria = "[strEmployeeID] = " & Me![strEmployeeID] & _
    "and [dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "


    --
    Phillip Windell [MCP, MVP, CCNA]
    www.wandtv.com
     
  5. Rambo

    Rambo
    Expand Collapse
    Guest

    Phillip Windell wrote:
    > "Rambo" <moneyball.wilson@gmail.com> wrote in message
    > news:1152289501.936710.183810@p79g2000cwp.googlegroups.com...
    > > Private Sub cmdPreviewRecord_Click()
    > > Dim strReportName As String
    > > Dim strCriteria As String
    > >
    > > str ReportName = "rptProgressReport"

    > ^--that space should not be there.
    >
    > > strCriteria = "[strEmployeeID] = ' " & Me![strEmployeeID] & " ' "

    >
    > Isn't EmployeeID a number? If so, it should not have single-quotes around
    > it.
    >
    > strCriteria = "[strEmployeeID] = " & Me![strEmployeeID]
    >
    >
    > > and "[dtmDateofProgress] = ' " & Me![dtmDateofProgress] & " ' "

    >
    > dtmDateOfProgress should not have single-quotes around it,..it is a Date
    > Type,..not a string. I believe Date Types are supposed to be enclosed
    > inside # when in an SQL query. There may be other syntax errors too.
    >
    > and "[dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "
    >
    > I could be wrong, but maybe it should look like this, or at least something
    > similar.
    >
    > strCriteria = "[strEmployeeID] = " & Me![strEmployeeID] & _
    > "and [dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "
    >
    >
    > --
    > Phillip Windell [MCP, MVP, CCNA]
    > www.wandtv.com


    In this case strEmployeeID is a text field.

    I have tried both ways and still can't seem to get rid of the error. I
    will keep on trying things out and if anyone comes up with any more
    suggestions I would be more than happy to try those too. Thanks for
    the effort though guys it is very much appreciated.

    Sincerely,
    Rambo
     
  6. Phillip Windell

    Phillip Windell
    Expand Collapse
    Guest

    You need to build debugging features into the form or use the script
    debugging tool. You need to verify what is being "produced" as the value
    for strCriteria before you actually use it.

    For example.
    Add a "debug" textbox to the form and make it long enough to view the whole
    value
    Comment out the "DoCmd.OpenReport" line.
    Then just above it add
    "debugbox.text = strCriteria"

    Run the form, make sure you get the right expected value showing in the text
    box. When it is correct delete the textbox and remove the extra code.

    I'm sure there are other ways to accomplish the same thing but it's all I
    could think of off the top of my head. I'm from the ASP Classic "world" and
    that is how we would handle those types of things with ASP Classic.

    --
    Phillip Windell [MCP, MVP, CCNA]
    www.wandtv.com

    "Rambo" <moneyball.wilson@gmail.com> wrote in message
    news:1152292865.970082.83920@k73g2000cwa.googlegroups.com...
    >
    > Phillip Windell wrote:
    >> "Rambo" <moneyball.wilson@gmail.com> wrote in message
    >> news:1152289501.936710.183810@p79g2000cwp.googlegroups.com...
    >> > Private Sub cmdPreviewRecord_Click()
    >> > Dim strReportName As String
    >> > Dim strCriteria As String
    >> >
    >> > str ReportName = "rptProgressReport"

    >> ^--that space should not be there.
    >>
    >> > strCriteria = "[strEmployeeID] = ' " & Me![strEmployeeID] & " ' "

    >>
    >> Isn't EmployeeID a number? If so, it should not have single-quotes around
    >> it.
    >>
    >> strCriteria = "[strEmployeeID] = " & Me![strEmployeeID]
    >>
    >>
    >> > and "[dtmDateofProgress] = ' " & Me![dtmDateofProgress] & " ' "

    >>
    >> dtmDateOfProgress should not have single-quotes around it,..it is a Date
    >> Type,..not a string. I believe Date Types are supposed to be enclosed
    >> inside # when in an SQL query. There may be other syntax errors too.
    >>
    >> and "[dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "
    >>
    >> I could be wrong, but maybe it should look like this, or at least
    >> something
    >> similar.
    >>
    >> strCriteria = "[strEmployeeID] = " & Me![strEmployeeID] & _
    >> "and [dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "
    >>
    >>
    >> --
    >> Phillip Windell [MCP, MVP, CCNA]
    >> www.wandtv.com

    >
    > In this case strEmployeeID is a text field.
    >
    > I have tried both ways and still can't seem to get rid of the error. I
    > will keep on trying things out and if anyone comes up with any more
    > suggestions I would be more than happy to try those too. Thanks for
    > the effort though guys it is very much appreciated.
    >
    > Sincerely,
    > Rambo
    >
     
  7. Duane Hookom

    Duane Hookom
    Expand Collapse
    Guest

    Phillip,
    Great tips. Actually in Access VBA, use:
    MsgBox "strCriteria: " & strCriteria
    or
    Debug.Print "strCriteria: " & strCriteria
    The debug results can be viewed by pressing Ctrl+G

    Rambo,
    When something doesn't work, come back with your exact code and exact error
    message. Apply the debug techique and also provide us the the results from
    the debug.print statement.


    --
    Duane Hookom
    MS Access MVP



    "Phillip Windell" <@.> wrote in message
    news:OND7u0foGHA.220@TK2MSFTNGP05.phx.gbl...
    > You need to build debugging features into the form or use the script
    > debugging tool. You need to verify what is being "produced" as the value
    > for strCriteria before you actually use it.
    >
    > For example.
    > Add a "debug" textbox to the form and make it long enough to view the
    > whole value
    > Comment out the "DoCmd.OpenReport" line.
    > Then just above it add
    > "debugbox.text = strCriteria"
    >
    > Run the form, make sure you get the right expected value showing in the
    > text box. When it is correct delete the textbox and remove the extra code.
    >
    > I'm sure there are other ways to accomplish the same thing but it's all I
    > could think of off the top of my head. I'm from the ASP Classic "world"
    > and that is how we would handle those types of things with ASP Classic.
    >
    > --
    > Phillip Windell [MCP, MVP, CCNA]
    > www.wandtv.com
    >
    > "Rambo" <moneyball.wilson@gmail.com> wrote in message
    > news:1152292865.970082.83920@k73g2000cwa.googlegroups.com...
    >>
    >> Phillip Windell wrote:
    >>> "Rambo" <moneyball.wilson@gmail.com> wrote in message
    >>> news:1152289501.936710.183810@p79g2000cwp.googlegroups.com...
    >>> > Private Sub cmdPreviewRecord_Click()
    >>> > Dim strReportName As String
    >>> > Dim strCriteria As String
    >>> >
    >>> > str ReportName = "rptProgressReport"
    >>> ^--that space should not be there.
    >>>
    >>> > strCriteria = "[strEmployeeID] = ' " & Me![strEmployeeID] & " ' "
    >>>
    >>> Isn't EmployeeID a number? If so, it should not have single-quotes
    >>> around
    >>> it.
    >>>
    >>> strCriteria = "[strEmployeeID] = " & Me![strEmployeeID]
    >>>
    >>>
    >>> > and "[dtmDateofProgress] = ' " & Me![dtmDateofProgress] & " ' "
    >>>
    >>> dtmDateOfProgress should not have single-quotes around it,..it is a Date
    >>> Type,..not a string. I believe Date Types are supposed to be enclosed
    >>> inside # when in an SQL query. There may be other syntax errors too.
    >>>
    >>> and "[dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "
    >>>
    >>> I could be wrong, but maybe it should look like this, or at least
    >>> something
    >>> similar.
    >>>
    >>> strCriteria = "[strEmployeeID] = " & Me![strEmployeeID] & _
    >>> "and [dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "
    >>>
    >>>
    >>> --
    >>> Phillip Windell [MCP, MVP, CCNA]
    >>> www.wandtv.com

    >>
    >> In this case strEmployeeID is a text field.
    >>
    >> I have tried both ways and still can't seem to get rid of the error. I
    >> will keep on trying things out and if anyone comes up with any more
    >> suggestions I would be more than happy to try those too. Thanks for
    >> the effort though guys it is very much appreciated.
    >>
    >> Sincerely,
    >> Rambo
    >>

    >
    >
     
  8. Rambo

    Rambo
    Expand Collapse
    Guest

    Hey Guys,

    Thanks for sticking with me. I will give this a shot today and get
    back to you.

    Sincerely,
    Rambo
    Duane Hookom wrote:
    > Phillip,
    > Great tips. Actually in Access VBA, use:
    > MsgBox "strCriteria: " & strCriteria
    > or
    > Debug.Print "strCriteria: " & strCriteria
    > The debug results can be viewed by pressing Ctrl+G
    >
    > Rambo,
    > When something doesn't work, come back with your exact code and exact error
    > message. Apply the debug techique and also provide us the the results from
    > the debug.print statement.
    >
    >
    > --
    > Duane Hookom
    > MS Access MVP
    >
    >
    >
    > "Phillip Windell" <@.> wrote in message
    > news:OND7u0foGHA.220@TK2MSFTNGP05.phx.gbl...
    > > You need to build debugging features into the form or use the script
    > > debugging tool. You need to verify what is being "produced" as the value
    > > for strCriteria before you actually use it.
    > >
    > > For example.
    > > Add a "debug" textbox to the form and make it long enough to view the
    > > whole value
    > > Comment out the "DoCmd.OpenReport" line.
    > > Then just above it add
    > > "debugbox.text = strCriteria"
    > >
    > > Run the form, make sure you get the right expected value showing in the
    > > text box. When it is correct delete the textbox and remove the extra code.
    > >
    > > I'm sure there are other ways to accomplish the same thing but it's all I
    > > could think of off the top of my head. I'm from the ASP Classic "world"
    > > and that is how we would handle those types of things with ASP Classic.
    > >
    > > --
    > > Phillip Windell [MCP, MVP, CCNA]
    > > www.wandtv.com
    > >
    > > "Rambo" <moneyball.wilson@gmail.com> wrote in message
    > > news:1152292865.970082.83920@k73g2000cwa.googlegroups.com...
    > >>
    > >> Phillip Windell wrote:
    > >>> "Rambo" <moneyball.wilson@gmail.com> wrote in message
    > >>> news:1152289501.936710.183810@p79g2000cwp.googlegroups.com...
    > >>> > Private Sub cmdPreviewRecord_Click()
    > >>> > Dim strReportName As String
    > >>> > Dim strCriteria As String
    > >>> >
    > >>> > str ReportName = "rptProgressReport"
    > >>> ^--that space should not be there.
    > >>>
    > >>> > strCriteria = "[strEmployeeID] = ' " & Me![strEmployeeID] & " ' "
    > >>>
    > >>> Isn't EmployeeID a number? If so, it should not have single-quotes
    > >>> around
    > >>> it.
    > >>>
    > >>> strCriteria = "[strEmployeeID] = " & Me![strEmployeeID]
    > >>>
    > >>>
    > >>> > and "[dtmDateofProgress] = ' " & Me![dtmDateofProgress] & " ' "
    > >>>
    > >>> dtmDateOfProgress should not have single-quotes around it,..it is a Date
    > >>> Type,..not a string. I believe Date Types are supposed to be enclosed
    > >>> inside # when in an SQL query. There may be other syntax errors too.
    > >>>
    > >>> and "[dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "
    > >>>
    > >>> I could be wrong, but maybe it should look like this, or at least
    > >>> something
    > >>> similar.
    > >>>
    > >>> strCriteria = "[strEmployeeID] = " & Me![strEmployeeID] & _
    > >>> "and [dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "
    > >>>
    > >>>
    > >>> --
    > >>> Phillip Windell [MCP, MVP, CCNA]
    > >>> www.wandtv.com
    > >>
    > >> In this case strEmployeeID is a text field.
    > >>
    > >> I have tried both ways and still can't seem to get rid of the error. I
    > >> will keep on trying things out and if anyone comes up with any more
    > >> suggestions I would be more than happy to try those too. Thanks for
    > >> the effort though guys it is very much appreciated.
    > >>
    > >> Sincerely,
    > >> Rambo
    > >>

    > >
    > >
     
  9. Rambo

    Rambo
    Expand Collapse
    Guest

    Hey,

    So I got the criteria function to work so thank you so much for your
    help!
    I have another question though. I am trying to get my above mentioned
    report to export to word. Do you happen to know the code to do that?

    Sincerely,
    Rambo

    Rambo wrote:
    > Hey Guys,
    >
    > Thanks for sticking with me. I will give this a shot today and get
    > back to you.
    >
    > Sincerely,
    > Rambo
    > Duane Hookom wrote:
    > > Phillip,
    > > Great tips. Actually in Access VBA, use:
    > > MsgBox "strCriteria: " & strCriteria
    > > or
    > > Debug.Print "strCriteria: " & strCriteria
    > > The debug results can be viewed by pressing Ctrl+G
    > >
    > > Rambo,
    > > When something doesn't work, come back with your exact code and exact error
    > > message. Apply the debug techique and also provide us the the results from
    > > the debug.print statement.
    > >
    > >
    > > --
    > > Duane Hookom
    > > MS Access MVP
    > >
    > >
    > >
    > > "Phillip Windell" <@.> wrote in message
    > > news:OND7u0foGHA.220@TK2MSFTNGP05.phx.gbl...
    > > > You need to build debugging features into the form or use the script
    > > > debugging tool. You need to verify what is being "produced" as the value
    > > > for strCriteria before you actually use it.
    > > >
    > > > For example.
    > > > Add a "debug" textbox to the form and make it long enough to view the
    > > > whole value
    > > > Comment out the "DoCmd.OpenReport" line.
    > > > Then just above it add
    > > > "debugbox.text = strCriteria"
    > > >
    > > > Run the form, make sure you get the right expected value showing in the
    > > > text box. When it is correct delete the textbox and remove the extra code.
    > > >
    > > > I'm sure there are other ways to accomplish the same thing but it's all I
    > > > could think of off the top of my head. I'm from the ASP Classic "world"
    > > > and that is how we would handle those types of things with ASP Classic.
    > > >
    > > > --
    > > > Phillip Windell [MCP, MVP, CCNA]
    > > > www.wandtv.com
    > > >
    > > > "Rambo" <moneyball.wilson@gmail.com> wrote in message
    > > > news:1152292865.970082.83920@k73g2000cwa.googlegroups.com...
    > > >>
    > > >> Phillip Windell wrote:
    > > >>> "Rambo" <moneyball.wilson@gmail.com> wrote in message
    > > >>> news:1152289501.936710.183810@p79g2000cwp.googlegroups.com...
    > > >>> > Private Sub cmdPreviewRecord_Click()
    > > >>> > Dim strReportName As String
    > > >>> > Dim strCriteria As String
    > > >>> >
    > > >>> > str ReportName = "rptProgressReport"
    > > >>> ^--that space should not be there.
    > > >>>
    > > >>> > strCriteria = "[strEmployeeID] = ' " & Me![strEmployeeID] & " ' "
    > > >>>
    > > >>> Isn't EmployeeID a number? If so, it should not have single-quotes
    > > >>> around
    > > >>> it.
    > > >>>
    > > >>> strCriteria = "[strEmployeeID] = " & Me![strEmployeeID]
    > > >>>
    > > >>>
    > > >>> > and "[dtmDateofProgress] = ' " & Me![dtmDateofProgress] & " ' "
    > > >>>
    > > >>> dtmDateOfProgress should not have single-quotes around it,..it is a Date
    > > >>> Type,..not a string. I believe Date Types are supposed to be enclosed
    > > >>> inside # when in an SQL query. There may be other syntax errors too.
    > > >>>
    > > >>> and "[dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "
    > > >>>
    > > >>> I could be wrong, but maybe it should look like this, or at least
    > > >>> something
    > > >>> similar.
    > > >>>
    > > >>> strCriteria = "[strEmployeeID] = " & Me![strEmployeeID] & _
    > > >>> "and [dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "
    > > >>>
    > > >>>
    > > >>> --
    > > >>> Phillip Windell [MCP, MVP, CCNA]
    > > >>> www.wandtv.com
    > > >>
    > > >> In this case strEmployeeID is a text field.
    > > >>
    > > >> I have tried both ways and still can't seem to get rid of the error. I
    > > >> will keep on trying things out and if anyone comes up with any more
    > > >> suggestions I would be more than happy to try those too. Thanks for
    > > >> the effort though guys it is very much appreciated.
    > > >>
    > > >> Sincerely,
    > > >> Rambo
    > > >>
    > > >
    > > >
     
  10. Duane Hookom

    Duane Hookom
    Expand Collapse
    Guest

    I just use the menu system to "Office Link" to Word.

    --
    Duane Hookom
    MS Access MVP

    "Rambo" <moneyball.wilson@gmail.com> wrote in message
    news:1152543751.187290.113220@h48g2000cwc.googlegroups.com...
    > Hey,
    >
    > So I got the criteria function to work so thank you so much for your
    > help!
    > I have another question though. I am trying to get my above mentioned
    > report to export to word. Do you happen to know the code to do that?
    >
    > Sincerely,
    > Rambo
    >
    > Rambo wrote:
    >> Hey Guys,
    >>
    >> Thanks for sticking with me. I will give this a shot today and get
    >> back to you.
    >>
    >> Sincerely,
    >> Rambo
    >> Duane Hookom wrote:
    >> > Phillip,
    >> > Great tips. Actually in Access VBA, use:
    >> > MsgBox "strCriteria: " & strCriteria
    >> > or
    >> > Debug.Print "strCriteria: " & strCriteria
    >> > The debug results can be viewed by pressing Ctrl+G
    >> >
    >> > Rambo,
    >> > When something doesn't work, come back with your exact code and exact
    >> > error
    >> > message. Apply the debug techique and also provide us the the results
    >> > from
    >> > the debug.print statement.
    >> >
    >> >
    >> > --
    >> > Duane Hookom
    >> > MS Access MVP
    >> >
    >> >
    >> >
    >> > "Phillip Windell" <@.> wrote in message
    >> > news:OND7u0foGHA.220@TK2MSFTNGP05.phx.gbl...
    >> > > You need to build debugging features into the form or use the script
    >> > > debugging tool. You need to verify what is being "produced" as the
    >> > > value
    >> > > for strCriteria before you actually use it.
    >> > >
    >> > > For example.
    >> > > Add a "debug" textbox to the form and make it long enough to view the
    >> > > whole value
    >> > > Comment out the "DoCmd.OpenReport" line.
    >> > > Then just above it add
    >> > > "debugbox.text = strCriteria"
    >> > >
    >> > > Run the form, make sure you get the right expected value showing in
    >> > > the
    >> > > text box. When it is correct delete the textbox and remove the extra
    >> > > code.
    >> > >
    >> > > I'm sure there are other ways to accomplish the same thing but it's
    >> > > all I
    >> > > could think of off the top of my head. I'm from the ASP Classic
    >> > > "world"
    >> > > and that is how we would handle those types of things with ASP
    >> > > Classic.
    >> > >
    >> > > --
    >> > > Phillip Windell [MCP, MVP, CCNA]
    >> > > www.wandtv.com
    >> > >
    >> > > "Rambo" <moneyball.wilson@gmail.com> wrote in message
    >> > > news:1152292865.970082.83920@k73g2000cwa.googlegroups.com...
    >> > >>
    >> > >> Phillip Windell wrote:
    >> > >>> "Rambo" <moneyball.wilson@gmail.com> wrote in message
    >> > >>> news:1152289501.936710.183810@p79g2000cwp.googlegroups.com...
    >> > >>> > Private Sub cmdPreviewRecord_Click()
    >> > >>> > Dim strReportName As String
    >> > >>> > Dim strCriteria As String
    >> > >>> >
    >> > >>> > str ReportName = "rptProgressReport"
    >> > >>> ^--that space should not be there.
    >> > >>>
    >> > >>> > strCriteria = "[strEmployeeID] = ' " & Me![strEmployeeID] & " '
    >> > >>> > "
    >> > >>>
    >> > >>> Isn't EmployeeID a number? If so, it should not have single-quotes
    >> > >>> around
    >> > >>> it.
    >> > >>>
    >> > >>> strCriteria = "[strEmployeeID] = " & Me![strEmployeeID]
    >> > >>>
    >> > >>>
    >> > >>> > and "[dtmDateofProgress] = ' " & Me![dtmDateofProgress] & " ' "
    >> > >>>
    >> > >>> dtmDateOfProgress should not have single-quotes around it,..it is a
    >> > >>> Date
    >> > >>> Type,..not a string. I believe Date Types are supposed to be
    >> > >>> enclosed
    >> > >>> inside # when in an SQL query. There may be other syntax errors
    >> > >>> too.
    >> > >>>
    >> > >>> and "[dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "
    >> > >>>
    >> > >>> I could be wrong, but maybe it should look like this, or at least
    >> > >>> something
    >> > >>> similar.
    >> > >>>
    >> > >>> strCriteria = "[strEmployeeID] = " & Me![strEmployeeID] & _
    >> > >>> "and [dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "
    >> > >>>
    >> > >>>
    >> > >>> --
    >> > >>> Phillip Windell [MCP, MVP, CCNA]
    >> > >>> www.wandtv.com
    >> > >>
    >> > >> In this case strEmployeeID is a text field.
    >> > >>
    >> > >> I have tried both ways and still can't seem to get rid of the error.
    >> > >> I
    >> > >> will keep on trying things out and if anyone comes up with any more
    >> > >> suggestions I would be more than happy to try those too. Thanks for
    >> > >> the effort though guys it is very much appreciated.
    >> > >>
    >> > >> Sincerely,
    >> > >> Rambo
    >> > >>
    >> > >
    >> > >

    >
     
  11. Rambo

    Rambo
    Expand Collapse
    Guest

    Dear Mr. Hookom,

    That works just fine. You have been a great help to me. Thank you
    very much.

    Sincerely,
    Rambo

    Duane Hookom wrote:
    > I just use the menu system to "Office Link" to Word.
    >
    > --
    > Duane Hookom
    > MS Access MVP
    >
    > "Rambo" <moneyball.wilson@gmail.com> wrote in message
    > news:1152543751.187290.113220@h48g2000cwc.googlegroups.com...
    > > Hey,
    > >
    > > So I got the criteria function to work so thank you so much for your
    > > help!
    > > I have another question though. I am trying to get my above mentioned
    > > report to export to word. Do you happen to know the code to do that?
    > >
    > > Sincerely,
    > > Rambo
    > >
    > > Rambo wrote:
    > >> Hey Guys,
    > >>
    > >> Thanks for sticking with me. I will give this a shot today and get
    > >> back to you.
    > >>
    > >> Sincerely,
    > >> Rambo
    > >> Duane Hookom wrote:
    > >> > Phillip,
    > >> > Great tips. Actually in Access VBA, use:
    > >> > MsgBox "strCriteria: " & strCriteria
    > >> > or
    > >> > Debug.Print "strCriteria: " & strCriteria
    > >> > The debug results can be viewed by pressing Ctrl+G
    > >> >
    > >> > Rambo,
    > >> > When something doesn't work, come back with your exact code and exact
    > >> > error
    > >> > message. Apply the debug techique and also provide us the the results
    > >> > from
    > >> > the debug.print statement.
    > >> >
    > >> >
    > >> > --
    > >> > Duane Hookom
    > >> > MS Access MVP
    > >> >
    > >> >
    > >> >
    > >> > "Phillip Windell" <@.> wrote in message
    > >> > news:OND7u0foGHA.220@TK2MSFTNGP05.phx.gbl...
    > >> > > You need to build debugging features into the form or use the script
    > >> > > debugging tool. You need to verify what is being "produced" as the
    > >> > > value
    > >> > > for strCriteria before you actually use it.
    > >> > >
    > >> > > For example.
    > >> > > Add a "debug" textbox to the form and make it long enough to view the
    > >> > > whole value
    > >> > > Comment out the "DoCmd.OpenReport" line.
    > >> > > Then just above it add
    > >> > > "debugbox.text = strCriteria"
    > >> > >
    > >> > > Run the form, make sure you get the right expected value showing in
    > >> > > the
    > >> > > text box. When it is correct delete the textbox and remove the extra
    > >> > > code.
    > >> > >
    > >> > > I'm sure there are other ways to accomplish the same thing but it's
    > >> > > all I
    > >> > > could think of off the top of my head. I'm from the ASP Classic
    > >> > > "world"
    > >> > > and that is how we would handle those types of things with ASP
    > >> > > Classic.
    > >> > >
    > >> > > --
    > >> > > Phillip Windell [MCP, MVP, CCNA]
    > >> > > www.wandtv.com
    > >> > >
    > >> > > "Rambo" <moneyball.wilson@gmail.com> wrote in message
    > >> > > news:1152292865.970082.83920@k73g2000cwa.googlegroups.com...
    > >> > >>
    > >> > >> Phillip Windell wrote:
    > >> > >>> "Rambo" <moneyball.wilson@gmail.com> wrote in message
    > >> > >>> news:1152289501.936710.183810@p79g2000cwp.googlegroups.com...
    > >> > >>> > Private Sub cmdPreviewRecord_Click()
    > >> > >>> > Dim strReportName As String
    > >> > >>> > Dim strCriteria As String
    > >> > >>> >
    > >> > >>> > str ReportName = "rptProgressReport"
    > >> > >>> ^--that space should not be there.
    > >> > >>>
    > >> > >>> > strCriteria = "[strEmployeeID] = ' " & Me![strEmployeeID] & " '
    > >> > >>> > "
    > >> > >>>
    > >> > >>> Isn't EmployeeID a number? If so, it should not have single-quotes
    > >> > >>> around
    > >> > >>> it.
    > >> > >>>
    > >> > >>> strCriteria = "[strEmployeeID] = " & Me![strEmployeeID]
    > >> > >>>
    > >> > >>>
    > >> > >>> > and "[dtmDateofProgress] = ' " & Me![dtmDateofProgress] & " ' "
    > >> > >>>
    > >> > >>> dtmDateOfProgress should not have single-quotes around it,..it is a
    > >> > >>> Date
    > >> > >>> Type,..not a string. I believe Date Types are supposed to be
    > >> > >>> enclosed
    > >> > >>> inside # when in an SQL query. There may be other syntax errors
    > >> > >>> too.
    > >> > >>>
    > >> > >>> and "[dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "
    > >> > >>>
    > >> > >>> I could be wrong, but maybe it should look like this, or at least
    > >> > >>> something
    > >> > >>> similar.
    > >> > >>>
    > >> > >>> strCriteria = "[strEmployeeID] = " & Me![strEmployeeID] & _
    > >> > >>> "and [dtmDateofProgress] = # " & Me![dtmDateofProgress] & " # "
    > >> > >>>
    > >> > >>>
    > >> > >>> --
    > >> > >>> Phillip Windell [MCP, MVP, CCNA]
    > >> > >>> www.wandtv.com
    > >> > >>
    > >> > >> In this case strEmployeeID is a text field.
    > >> > >>
    > >> > >> I have tried both ways and still can't seem to get rid of the error.
    > >> > >> I
    > >> > >> will keep on trying things out and if anyone comes up with any more
    > >> > >> suggestions I would be more than happy to try those too. Thanks for
    > >> > >> the effort though guys it is very much appreciated.
    > >> > >>
    > >> > >> Sincerely,
    > >> > >> Rambo
    > >> > >>
    > >> > >
    > >> > >

    > >
     

Share This Page