Results 1 to 4 of 4
  1. #1
    jak82 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Aug 2012
    Posts
    2

    Question Help with query

    Hi All,

    I have a query which checks a linked table for any records older than a year that havnt had a service.

    I presume in the criteria field for org name I would put Not [dbo_flowitems].[name].["serviced"]

    Is this correct? Also the line above does not work

    What would the correct syntax be?

    The sql is

    SELECT dbo_flowitems.name, dbo_orgs.orgtype, dbo_orgs.orgname, dbo_people.firstname, dbo_people.lastname, dbo_people.role, dbo_people.email, [Year Reminder].[Emailed?], dbo_flows.flowdate, dbo_flows.flowtype


    FROM [Year Reminder], (((dbo_orgs INNER JOIN dbo_calibrations ON dbo_orgs.id = dbo_calibrations.id) INNER JOIN dbo_people ON dbo_calibrations.id = dbo_people.id) INNER JOIN dbo_flows ON dbo_orgs.id = dbo_flows.orgid) INNER JOIN dbo_flowitems ON dbo_flows.id = dbo_flowitems.flowid
    WHERE (((dbo_flows.flowtype)="Accounts Invoice") AND ((CDate(Format([flowdate],"dd/mm/yyyy")))<Date()-365));


    The error message I get is

    ODBC call failed
    [sqlserver] The datatypes text and varchar are incompatible in the equal to operator



    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    You have a field actually named 'name'? Better would be OrgName as Name is a reserved word.

    That syntax definitely makes no sense whatsoever.

    If the criteria is whether or not service is done, then is there a field called 'Serviced'? Is it a Yes/No? Apply critieria to that field.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    jak82 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Aug 2012
    Posts
    2
    Quote Originally Posted by June7 View Post
    You have a field actually named 'name'? Better would be OrgName as Name is a reserved word.

    That syntax definitely makes no sense whatsoever.

    If the criteria is whether or not service is done, then is there a field called 'Serviced'? Is it a Yes/No? Apply critieria to that field.
    No unfortunatly I am using a legacy sqlserver database which has other programs attached to it, the 'routine service' is in a text field called name.

    I need the criteria to check the name 'routine service' against the company and remove all instances of the company from the query.

    HTH

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    So there is a value of 'routine service' under field 'Name'? You want to exclude all records with 'routine service' in 'Name' field? Your original example has value 'serviced'. Which is it - 'serviced' or 'routine service'?

    Try:
    [dbo_flowitems].[name]<>"routine service"

    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums