English 中文(简体)
插入中转换数据类型
原标题:Convert datatypes in Access Insert

OK 是我的问题。 我有一个 Csv 文件, 它是由我控制产生的, 它包含同一文件的不同组的数据。 前七行是每个组的表格页头, 每个组不同。 因此首先我将这个文件导入到 Access 中。 我自此创建了访问单个组以进行数据分析的查询。 问题在于我需要在一个字段上使用一个表达式, 但是它必须是文本才能从电子表格中导入, 因为每个列含有数字和字符, 因为顶部的页眉有问题, 有时数据不正确, 需要按摩 。 所以我想要做的是将每个组插入到自己的表格中, 但是我要将一些列转换为数字, 这样我的表达式才会起作用 。 我将张贴我遇到问题的表达式 。 谢谢 。

    Sum(IIf([2000 Query].[Field19]=1,IIf([5000 Query].[Field21]>0,-[5000 Query].[Field21],[5000 Query].[Field21]),[5000 Query].[Field21])) AS [ADJ Invoice Total]
最佳回答

CDec :

IIf(CDec([2000 Query].[Field19])=1 ...

它的工作原理是这样的:

?cdec(" 20,121.34 ")
20121.34

所以逗号 领先和后行空间应该没问题

CDec在VBA中提供,但在MS Access查询中不提供。 在查询中,Val将工作:

IIf(Val([2000 Query].[Field19])=1 ...

或CDBL,它会接受 千个逗号分隔器 以及引导和跟踪空间。

问题回答

暂无回答




相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Outlook 2007 CommandBarControl.Execute won t work

I recently switched to Outlook 2007 and noticed that my VBA-macros won t work. I use the following code to open a new appointment-item (and fill it automatically). It worked perfect in Outlook 2003, ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

热门标签