ACC2000: Cannot Use Intrinsic Constants in Queries, Forms, Reports (209903)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q209903
Moderate: Requires basic macro, coding, and interoperability skills.

SYMPTOMS

When you use Microsoft Access intrinsic constants in expressions in a query, on a form or a report, or in the Condition column of a macro, you may receive an error.

For example, when you use the StrConv() function in the Update To cell of an update query and then run it, you receive the following error message:
Microsoft Access can't update all the records in the update query.
When you use the StrConv() function in the Criteria cell of a select query, you receive the following error message:
Data type mismatch in criteria expression.
If you use the StrConv() function in the ControlSource property of a control on a report, Microsoft Access prompts you for a parameter value.

If you use the StrConv() function in the ControlSource property of a control on a form, the control displays #Name? in Form view.

If you use the StrConv() function in the Condition column of a macro, you receive the following error message:
Microsoft Access can't find the name '<intrinsic constant name>' you entered in the expression.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

CAUSE

The query does not recognize the value of the Visual Basic intrinsic constants that you used in the function.

RESOLUTION

To work around this behavior, use one of the following methods:
  • Use the numeric value for the conversion argument instead of the constant. For example, instead of using

    Expr1: StrConv([CompanyName],vbProperCase)

    use:

    Expr1: StrConv([CompanyName],3)

  • use: Create a procedure that contains the built-in function with its intrinsic constant, and then use that procedure in your query. For example, you can create the following procedure in a module:
    Function UseConstants(FieldName As String)
       UseConstants = StrConv(FieldName, vbUpperCase)
    End Function
    						
    Then you can use the custom procedure in your query expression:

    Expr1: UseConstants([CompanyName])

STATUS

This behavior is by design. Intrinsic constants can only be used in Visual Basic for Applications code.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Start Microsoft Access and open the sample database Northwind.mdb.
  2. Create the following new query in Design view based on the Customers table:
       Query: qryCustomers
       ---------------------------------------------------------
       Type: Select Query
    
       Field: CompanyName
          Table: Customers
          Criteria: StrConv([CustomerID], vbLowerCase) = "alfki"
    					
  3. On the Query menu, click Run. Note that you receive the error "Data type mismatch in criteria expression." Click OK.
  4. Delete the Criteria expression and type the following expression in a new column in the QBE grid:

    StrConv([CompanyName], vbUpperCase)

  5. On the Query menu, click Run. Note that you receive the error mentioned earlier.
  6. Switch the query back to Design view.
  7. On the Query menu, click Update Query.
  8. In the QBE grid, delete the column with the StrConv expressions, and set the Update To cell of the CompanyName column to the following expression:

    StrConv([CompanyName], vbUpperCase)

  9. On the Query menu, click Run. Click Yes to confirm that you want to update the records, and note that you receive the error "Microsoft Access can't update all the records in the update query." Click No to stop the update.

REFERENCES

For more information about a list of numeric values associated with each of the intrinsic constants used in the conversion argument of the StrConv() function, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type StrConv()() function in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

For additional information about using the StrConv() function in Microsoft Access, click the article number below to view the article in the Microsoft Knowledge Base:

253911 ACC2000: How to Use the StrConv Function to Capitalize Words and Phrases


Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kberrmsg kbofficeprog kbprb kbProgramming kbusage KbVBA KB209903