查找值不存在时返回错误 [英] Returns error when the look up value do not exist

查看:95
本文介绍了查找值不存在时返回错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当当前记录中不存在[Status] =''For Signature'下的查找值时,代码返回错误,其中显示错误[disc] =''books''找不到错误..当查找[status]值在列表/记录上时,代码工作。


我想让代码继续执行并返回空值,即使查找[status]值不再存在。


请帮助,谢谢

展开 | 选择 | Wrap | 行号

解决方案

Hello Welcome to Bytes。


你没有提到正在给出的错误,我怀疑它是无效的使用null。


你发布的代码的第3行看起来有点不对。

如果记录计数intNoOfIA3为7,那么Line7为零,那么 Dlook up()返回一个空值,然后您尝试将该函数[fAppendIANum3]类型转换为字符串;但是,字符串不接受空值,所以你得到一个错误。


你在17行的字符串开始你的记录集...我想你应该继续打开这条记录-set从一开始就从那里开始。


我不知道为什么要将查询添加到你的定义中,看起来似乎并不需要。 />

让我仔细看看你在这里发生了什么......


你好Zmbd,谢谢你的回复。


如果字段中列出了条件(''签名''),则代码可以正常工作。一旦标准(即签名)未在当前[状态]字段中列出,它就会变成错误。


TBXQuery是我的表记录源(没有空字段)。 (我必须创建它,因为我有空值的错误)。


错误变成这样:


语法错误(缺少运算符)在查询表达式''[Disc] = yyyy''和[Status] =''For Signature''。


< blockquote>这将是第一个错误:)


我强烈建议通过我们的基本故障排除部分阅读,我会给你一份我的锅炉盘有这个链接和另外,希望,有用的信息。


另外,因为你已经在你发布的代码上付出了太多的努力,我想我会看到是否有一个修复。


请尝试以下方法....


在您的数据库副本中(我总是推荐一份副本!)

从功能区创建一个新模块,然后剪切并粘贴以下代码(提示,单击行号,然后展开,最后选择然后< ctrl>< C>)

展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号


When the Look up value under the [Status]=''For Signature'' do not exist in the current record, the code returns an error where it says error [disc] = ''books'' cannot be found error..however the code works when the look up [status] value is on the list/record.

I want to have the code to continue the execution and return empty values even the look up [status] value do not exist anymore.

Please help, thanks

Expand|Select|Wrap|Line Numbers

解决方案

Hello Welcome to Bytes.

You don''t mention what error is being given, I suspect it''s an invalid use of null.

Line3 of your posted code looks a bit off.
Line7 if the record count, intNoOfIA3, is zero then the Dlookup() returns a null value which you then attempt to assign to the function [fAppendIANum3] type-cast as a string; however, strings do not accept the null value so you get an error.

String in Line17 you start your record-set... I think you should just go ahead and open this record-set from the start and go from there.

I''m not sure why you are adding the query to your definitions, it doesn''t appear to be needed.

Let me take a careful look at what it appears you have going on here....


Hi Zmbd, thank you for the response.

The code works perfectly fine, if the criteria (''For Signature'') is listed in the field. It only becomes an error, once the criteria (i.e. for signature) is not listed in the current [Status] field.

the TBXQuery is my table record source (no null fields). (I have to create it, because I am having errors for null values).

The error becomes like this:

syntax error (missing operator) in query expression ''[Disc] = yyyy'' AND [Status] = ''For Signature''.


that will be the first error :)

I highly advise reading thru our basic trouble shooting section, I''ll PM you a copy of my boiler plate that has that link and other, hopefully, helpful information.

Also, because you''ve put so much effort into the code you''ve posted, I thought I''d see if there was a fix.

Try the following....

In a copy of your database (I always recommend a copy!)
From the ribbon, create a new module and then cut and paste the following code (hint, click on the line numbers, then expand, finally Select then <ctrl><C> )

Expand|Select|Wrap|Line Numbers


这篇关于查找值不存在时返回错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆