VFP中“文件正在使用”错误

来源:百度知道 编辑:UC知道 时间:2024/05/19 05:22:33
我建了一个表"药品明细",其中有个字段是日期型的
想通过在一个组合框中输入日期来查询整行记录 代码如下
thisform.combo1.setfocus()
isempty=allt(thisform.combo1.value)
if isempty==''
=messagebox("请输入您要查询的日期!",64,"提示窗口")
else
use 动态报表设计\药品明细.dbf
locate for 药品明细.日期=isempty
if found()
select 药品明细.日期,药品明细.型号,;
药品明细.药品名称,药品明细.类别 from 青海明胶公司药品数据库!药品明细 药品明细;
where(药品明细.日期=isempty);
order by 药品明细.日期
go top
thisform.combo1.value=''
thisform.combo1.setfocus()
isempty=allt(thisform.combo1.value)
else
=messagebox("查询不到结果!",64,"提示窗口")
thisform.combo1.value=''
thisform.combo1.setfocus()
isempty=allt(thisform.combo1.v

问题很简单:use 动态报表设计\药品明细.dbf之前要判断药品明细.dbf是否已经打开。

如未打开,则利用USE命令打开,如已经打开,利用SELECT命令选择即可。

if !used("药品明细")
use 药品明细 in 0
endif

select 药品明细
locate for 药品明细.日期=isempty
if found()
......以下代码略。

load事件就不用改了。

文件正在使用。(错误 3)
试图使用 USE、DELETE 或者 RENAME 命令操作文件,而此文件已经打开。

把:use 动态报表设计\药品明细.dbf :这句拿到最前边。即应该在在表单的load事件中写入:use 动态报表设计\药品明细.dbf in 0 alias 药品明细
在你写use 动态报表设计\药品明细.dbf 的地方改为 sele 药品明细

将use 动态报表设计\药品明细.dbf
改为:
if not used('药品明细')
use 动态报表设计\药品明细.dbf in 0
endif
select 药品明细