Results 1 to 6 of 6
  1. #1
    kraigt84 is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2013
    Posts
    3

    Replace: Data type mismatch in Criteria Expression

    By no means am I an expert is Access Programming, but I am building a query to inspect and field and look for "null" data, then replace it with a field that has data in it.



    I can get the query to find null data without issue, just cant seem to get the replace function to work.

    I checked both fields and both data types are "text"

    So far I have built the function:

    Replace([Branch update]![Sector],Is Null,[Branch update]![Employee JobFamName])

    Here is the SQL view of my query:

    SELECT [Branch update].[Region Name], [Branch update].[Desktop Serial No], [Branch update].[Desktop Assignment], [Branch update].[Hardware Brand Name], [Branch update].[Hardware Model Name(3rd Level)], [Branch update].[Desktop Model Name], [Branch update].[Hardware Model Name(4th Level)], [Branch update].[Date Counter], [Branch update].[Desktop Last Scan Date], [Branch update].Userlogin, [Branch update].[Employe Status], [Branch update].[Employee Fullname], [Branch update].[Location Country Name], [Branch update].City, [Branch update].State, [Branch update].Address1, [Branch update].[Desktop IP address], [Branch update].[Desktop Disk Size(MB)], [Branch update].[Desktop Memory size (MB)], [Branch update].[Desktop Operating System], [Branch update].ModelcitidtEOS, [Branch update].ModelcitidtProductLaunch, [Branch update].[GTAM ID], [Branch update].[Name (Sub-model ofSub-model of)], [Branch update].[CATE Win 7 Supported], [Branch update].[Employee JobFamName], [Branch update].Sector
    FROM [Branch update]
    WHERE ((([Branch update].Sector)=Replace([Branch update]![Sector],([Branch update].Sector) Is Null,[Branch update]![Employee JobFamName])));

    Any suggestion would be much appreciated!

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904

  3. #3
    kraigt84 is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2013
    Posts
    3
    Okay tried that but now I am getting the records that don't have a "null" value

    Nz([Branch update]![Sector],[Branch update]![Employee JobFamName])

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    If you just want to return records where the Sector field is Null, then your criteria should look like:
    Code:
    WHERE [Branch update]![Sector] is Null
    If you want to replace the value being returned using the NZ function, you would do that in that SELECT section of the SQL code.

    If this is not what you want to do, then perhaps you could post a small sample and your expected output. That might clarify exactly what you are trying to do.

  5. #5
    kraigt84 is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2013
    Posts
    3
    Please see the example below what I want to do is any where there is a blank "null" I want to move the information to the left of the yellow highlight in to the Sector column.

    Click image for larger version. 

Name:	example.JPG 
Views:	8 
Size:	36.8 KB 
ID:	11303

  6. #6
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I think you just want a simple IIF statement. Place it in your SELECT portion, NOT in the WHERE clause.
    Code:
    Sector:IIF(IsNull([Branch update]![Sector]),[Branch update]![Employee JobFamName],([Branch update]![Sector])

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

Similar Threads

  1. Data type mismatch in criteria expression
    By bobt_1234 in forum Queries
    Replies: 3
    Last Post: 02-13-2012, 03:37 PM
  2. Data Type mismatch in criteria expression
    By elb1999 in forum Queries
    Replies: 2
    Last Post: 01-20-2012, 02:38 PM
  3. Data type mismatch in criteria expression
    By buienxg in forum Access
    Replies: 2
    Last Post: 11-22-2011, 10:29 AM
  4. Data type mismatch in criteria expression
    By Douglasrac in forum Forms
    Replies: 3
    Last Post: 11-23-2010, 10:46 AM
  5. data type mismatch in criteria expression
    By broecher in forum Access
    Replies: 4
    Last Post: 09-10-2010, 08:29 AM

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