构建访问应用程序“库存” [英] Building Access Applications "Inventory"

查看:60
本文介绍了构建访问应用程序“库存”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过John L Viescas复制建筑物访问应用程序中的库存数据库

但是当我尝试运行数据库时,我在

订单中收到错误当我点击分配按钮时出现意外错误:3251
此类对象不支持
操作。演示cd有两个

数据库,一个是称为库存,另一个只有表格为

设计称为库存数据。当你运行库存数据库工作正常

所以我想我会使用数据中的表格。然后从库存中导入

查询和表格,一切正常,直到我想

将产品分配给客户,我比较了两个数据库中的表格
并且它们是准确的,除了库存是链接数据库,这是

我认为是问题而且表本身就是tblInventory。是

那里有几个人有这本书,知道我在做什么

错了或知道怎样做才能使它成为

解决方案

我们需要更多地了解失败的程序。


它包括这一行:

设置rs = db.OpenRecordset(" SomeTable")

try:

设置rs = db.OpenRecordset(" SomeTable",dbOpenDynaset)

如果这不起作用,请发布失败的行,以及任何一行

以上的行。


OpenRecordset对于附加表,默认为动态集类型,对于本地表,默认为表

类型。如果这是问题,那么声明动态集类型

应该解决此类对象不支持操作的问题。错误。


-

Allen Browne - 微软MVP。西澳大利亚州珀斯。

访问用户提示 - http:// allenbrowne.com/tips.html

回复群组,而不是mvps dot org的allenbrowne。


" royaltiger" < SG ***** @ ntlworld.com>在消息中写道

news:yt ******************* @ newsfe2-win.ntli.net ...

我正在尝试复制John L Viescas建筑访问应用程序中的库存数据库,但是当我尝试运行数据库时,当我点击分配按钮时,我在
订单表单中收到错误;此类对象不支持;意外错误:3251
操作。演示cd有两个数据库,一个叫做库存,另一个只有表格用于设计调用库存数据。当您运行库存时,数据库工作正常,所以我想我会使用数据中的表格。然后从库存中导入
查询和表单,一切正常,直到我想要将产品分配给客户,我已经比较了两个数据库中的表
它们是完全正确的,除了库存是一个链接数据库,这是我认为的问题,而表本身就是tblInventory。有没有几个人有这本书,知道我在做什么
错误或知道该怎么做才能做到正确



这是on click procedure中的代码。如果这也有帮助,那么

也是放置在模块中的AllocateProducts函数。

感谢您的尝试

Private Sub cmdAllocate_Click ()

Dim intReturn As Integer,db As DAO.Database,qdA As DAO.QueryDef,rsA As

DAO.Recordset

''用户已请求分配/订购产品

''设置本地错误陷阱,同时尝试将焦点放回原点

On Error Resume Next

屏幕。 PreviousControl.SetFocus

''设置错误陷阱

On Error GoTo cmdAllocate_ERR

''确保上次编辑已保存

如果不是SaveIt()则退出Sub

''指向此数据库

设置db = DBEngine(0)(0)

''获取查找产品的查询状态=无

设置qdA = db.QueryDefs(" zqryOrderProductSelect")

''设置此订单的参数

qdA![OrderParm] = CLng(Me.Parent!OrderID)

''查看是否找到记录

设置rsA = qdA.OpenRecordset()

''如果没有,请告诉他们并退出

如果rsA .RecordCount = 0然后

MsgBox无需分配。,vbInformation,gstrAppTitle

rsA.Close

设置rsA =无br />
退出Sub

结束如果

rsA.Close

设置rsA =无任何

''调用分配函数并传递给它这个订单ID

intReturn = AllocateProducts(CLng(Me.Parent!OrderID))

''检查返回值

选择案例intReturn

''真=全部确定

案例-1

''重新询问自己以显示更新状态

Me.Requery

MsgBox产品分配成功完成!,

vbInformation,gstrAppTitle

''错误返回 - 发生了一些错误

案例0

MsgBox"尝试分配产品时发生错误

for this&q UOT; &安培; _

" order。",vbExclamation,gstrAppTitle

''1 =分配,但建立了一些采购订单

案例1

MsgBox"并非所有产品都在库存中。一个或多个

购买订单 &安培; _

"已生成。",vbInformation,gstrAppTitle

结束选择


cmdAllocate_Exit:

退出Sub


cmdAllocate_ERR:

Dim lngErr As Long,strError As String

lngErr = Err

strError =错误

ErrorLog Me.Name& " _cmdAllocate",lngErr,strError

MsgBox"意外错误:" &安培; lngErr& , &安培; strError& "已记录

。",_

vbCritical,gstrAppTitle

恢复cmdAllocate_Exit


" ;艾伦布朗 <铝********* @ SeeSig.Invalid>在消息中写道

news:44 *********************** @ per-qv1-newsreader-01.iinet.net。 au ...

我们需要更多地了解失败的程序。

它包括这一行:
设置rs = db.OpenRecordset( SomeTable)尝试:
设置rs = db.OpenRecordset(" SomeTable",dbOpenDynaset)
如果这不起作用,请发布失败的行,并且任何像上面那样的行。

OpenRecordset默认为附加表的动态集类型,但是默认为本地表的表类型。如果这是问题,那么声明动态动态类型应该解决这种类型的对象不支持操作。错误。

-
Allen Browne - 微软MVP。西澳大利亚州珀斯。
访问用户提示 - http://allenbrowne.com/ tips.html
回复群组,而非mvps dot org的allenbrowne。

royaltiger < SG ***** @ ntlworld.com>在消息中写道
新闻:yt ******************* @ newsfe2-win.ntli.net ...

我是试图通过John L Viescas复制建筑物访问应用程序中的库存数据库,但是当我尝试运行数据库时,当我点击分配按钮意外错误时,我会在
订单表单中收到错误消息。 :3251
此类对象不支持此操作。演示CD有两个数据库,一个叫库存,另一个只有表格,称为库存数据。当你运行库存数据库
工作正常,所以我想我会使用数据中的表格。然后从库存中导入查询和表单,一切正常
直到我想将产品分配给客户,我比较了两个数据库中的表格,除了库存是一个链接的数据库,这就是我认为的问题而且表本身就是
tblInventory。是否有一些人有这本书,知道我做错了什么或知道该怎么做才能做到正确




这是一个名为

modInventory的模块中的AllocateProducts函数。

选项比较数据库''使用数据库顺序进行字符串比较
选项显式

Dim mlngLineNum为Long,mlngErr为Long,mstrError为String


函数AllocateProducts(lngOrder As Long,_

可选intSilent As Integer = 0,_

可选varDate As Variant)作为整数

''

''输入:订单ID

''可选运行无声指标(由zfrmLoadData使用)

''可选的处理日期(由zfrmLoadData使用)

''

''输出:返回" True" ; (-1)如果所有产品成功分配

''如果分配产品和采购订单,则返回+1

''返回" False" (0)如果发生错误

''

''技术:

''此例程尝试分配所需的产品。

''使用'zqryOrderProductSelect"查找状态不符合的产品

''在订单,已分配或已开票。如果退回产品

(负数

''数量),可以根据需要过帐到库存或原始采购订单。

''如果产品正在订购(正数量),从库存中分配

''。在分配结束时,如果某些仍未从

''库存中分配,则将无序产品填入ztTblProductsToOrder

''并调用公共PO构建例程。

''

''注意:当从zfrmLoadData调用时,intSilent为True - 程序将

''打开没有表格,不会显示任何错误。 zfrmLoadData也

''传递它想要用作分配/ PODate日期的日期。

''

Dim db作为DAO.Database ,qd作为DAO.QueryDef,qdA作为DAO.QueryDef

Dim rsA作为DAO.Recordset,rsI作为DAO.Recordset,rsS作为DAO.Recordset

Dim rst作为DAO .Recordset,rsP As DAO.Recordset,rsC As DAO.Recordset

Dim varQuantity As Variant,intQuantityReq As Integer

Dim varRet As Variant,intEditA As Integer,intRecCount As Integer

Dim intI As Integer,intSomeError As Integer,intSomeLeft As Integer

Dim intCount As Integer,intQty As Integer,intMult As Integer

Dim intL作为整数,curMinPrice作为货币,curCost作为货币

Dim curPrice作为货币,varCost作为Variant,varPrice作为Variant

Dim lngPO作为Long,lngVendor作为Long,intTrans作为整数

Dim lngProductID As Long,lngThisLine As Long,intAddedSome As Integer

Dim intDoPO As Integer,dat AllocDate As Date,lngVend As Long

Dim rstW作为DAO.Recordset,strSQL As String,strMsg As String


On Error Resume Next

''设置为默认虚假退货

AllocateProducts = 0


''设置分配日期

datAllocDate =日期

''如果传递了日期变量

如果不是IsMissing(varDate)那么

''..它是有效的date

If IsDate(varDate)Then

''使用参数值

datAllocDate = varDate

结束If

结束如果


''指向此数据库

设置db = DBEngine(0)(0)

''打开订单并锁定它!

设置rstW = db.OpenRecordset(" Select OrderID From tblOrders" &安培; _

" Where OrderID =" &安培; lngOrder)

如果rstW.EOF那么

如果不是intSilent然后

MsgBox"意外错误:找不到订单#" &安培; _

lngOrder,vbCritical,gstrAppTitle

结束如果

退出功能

结束如果

''通过编辑锁定订单

rstW.Edit

如果Err<> 0然后

strMsg ="错误尝试编辑订单#" &安培; lngOrder

strMsg = strMsg& " ;.其他人可能正在编辑此订单。

如果不是intSilent那么MsgBox strMsg,vbExclamation,gstrAppTitle

退出功能

结束如果


''设置一个错误陷阱

On Error GoTo AllocOrderProducts_ERR


''清理工作台以存储产品而不是有货

db.Execute" Delete * FROM zttblProductsToOrder;",dbFailOnError


''打开沙漏并开始交易

DoCmd.Hourglass True

BeginTrans

intTrans = True


''打开要分配的产品的记录集

设置qdA = db.QueryDefs(" zqryOrderProductSelect")

qdA![OrderParm] = lngOrder

设置rsA = qdA.OpenRecordset()

''打开库存表

设置rsI = db.OpenRecordset(" tblInventory")


''获取计数产品为SysCmd分配行

rsA.MoveLast

intRecCount = rsA.RecordCount

rsA.MoveFirst


''显示进度表

varRet = SysCmd( acSysCmdInitMeter,更新库存......,intRecCount)


''遍历所有产品进行分配,从库存中扣除,

''和调整主库存行

直到rsA.EOF

''如果退回产品,...

如果rsA![AmtNeeded]< 0然后

''看看是否返回采购订单

如果IsNothing(rsA!OrderPONo)那么

''如果没有PO到信用,然后返回库存

intQty = rsA![AmtNeeded]

''查找库存记录

rsI.FindFirst" ProductID = " &安培; rsA!ProductID

如果rsI.NoMatch那么

''哎呀 - 找不到要返回的库存记录

''产品!

intSomeError = True

strMsg ="尝试退回产品时出错#

strMsg = strMsg& rsA!ProductID& "库存。

strMsg = strMsg& "未找到库存记录。

strMsg = strMsg& "订单记录已被删除。

如果不是intSilent那么MsgBox strMsg,_

vbCritical,gstrAppTitle

''删除订单行

rsA.Delete

否则

''找到库存行 - 编辑它以锁定它

rsI。编辑

''查找库存退货的匹配库存行

strSQL ="选择*来自tblStock其中([ProductID] ="

strSQL = strSQL& rsA!ProductID

strSQL = strSQL&")和([Cost] ="& rsA!Cost&")"

''如果有VendorID,那么也过滤供应商

如果Not IsNothing(rsA!VendorID)那么

strSQL = strSQL& " AND([VendorID] ="& _

rsA!VendorID&")"

lngVendor = rsA!VendorID

结束如果

''打开股票记录集

设置rsS = db.OpenRecordset(strSQL)

如果rsS.EOF那么

''哎呀 - 找不到要返回的股票行

''产品!

intSomeError = True

strMsg ="尝试返回产品错误#"

strMsg = strMsg& rsA!ProductID& "库存。

strMsg = strMsg& "与

strMsg = strMsg&匹配的股票记录找不到供应商和成本。

strMsg = strMsg& "订单记录已被删除。

如果不是intSilent那么MsgBox strMsg,_

vbCritical,gstrAppTitle

''删除订单行

rsA.Delete

否则

''将产品退回库存记录

rsS.Edit

''减去已分配金额 -

''产品现已有库存回复

''注意:QuantityAllocated如果

''先前已分配的产品已经开票,那么可能是负面的。
''开具发票。当发票项目

贷记时将更正。

rsS!QuantityAllocated = rsS!QuantityAllocated + _

rsA!AmtNeeded

rsS!QuantityRemaining = rsS!数量 - _

(rsS!QuantityAllocated + rsS!QuantitySold + _

rsS!QuantityReturned)

lngVendor = rsS!VendorID

rsS.Update

intQuantityReq = 0

结束如果

rsS.Close

''刷新主库存总数...

rsI.Edit

''在这里使用查询以便此例程将

''查看交易中的更新数量。

设置qd = db.QueryDefs(" zqrySumStockParm")

qd!ItemToFind = rsA!ProductID

设置rst = qd.OpenRecordset()

''更新库存行中的计算值。

如果不是rst.EOF那么

rsI!HighCost = rst!MaxCost

rsI!QuantityInStock = rst!可用

rsI!QuantityOnHand = rst!Remain

Else
rsI!QuantityInStock = 0

rsI!QuantityOnHand = 0

结束如果

rst.Close

Set rst = Nothing

qd.Close

设置qd = Nothing

rsI.Update


''更新订单状态

rsA.Edit

rsA!Status = OrderStatus.Allocated

rsA!DateAlloc = datAllocDate

rsA!VendorID = lngVendor

rsA.Update

结束如果

否则

''有一个PO编号,所以归功于PO!

''在PO产品上打开记录集以插入行

设置rsP = db.OpenRecordset (zqryPOProductsForAlloc,_

dbOpenDynaset,dbAppendOnly)

''插入一个新的PO产品行来排队信用额

''得到下一个行号 -

''必须在事务中使用记录集!

设置rsC = db.OpenRecordset("选择最大值([LineNo])为

[LastLineNo]"& _

" from tblPOProducts"& _

" Where [PONumber] ="& rsA! OrderPONo)

如果是IsNull(rsC!LastLineNo)那么

intL = 1

否则

intL = rsC! LastLineNo + 1

结束如果

rsC.Close

rsP.AddNew

rsP!PONumber = rsA!OrderPONo

''设置采购订单编号应该是autolookup

''来自PO的供应商ID

如果IsNothing(rsP!POVend)然后

''哎呀 - 意味着PO不存在!

如果不是intSilent然后

MsgBox"错误尝试贷记产品#" ; &安培; _

rsA!ProductID& "购买订单#" &

rsA!OrderPONo& _

。无法找到采购订单。 " &安培; _

订单中的采购订单编号已归零。,_

vbCritical,gstrAppTitle

结束如果

intSomeError = True

rsA.Edit

''清空采购订单编号

rsA!订单编号= 0

rsA.Update

''丢弃POP产品行

rsP.Close

设置rsP = Nothing

Else

''好的 - 有一个好的PO,所以设置其余的字段

rsP!LineNo = intL

''复制采购订单中的供应商ID

rsP!VendorID = rsP!POVend

lngVendor = rsP!POVend

''复制产品ID

rsP!ProductID = rsA!ProductID

''保存所需数量

intQty = rsA![AmtNeeded]

''..和订单倍数

''(一个购买单位的销售单位数量)

intMult = rsA![OrderMultiple]

''设置退货数量

rsP!SellQuantity = intQty

''如果数量是偶数倍

如果intQty Mod intMult = 0那么

''做一个整数除以得到订单金额

rsP!BuyQuantity = intQty \ intMult

否则

''其他一轮到下一个购买金额

rsP !BuyQuantity =(intQty \ intMult)+ 1

结束如果

''按顺序设置(案例,托盘)

rsP!OrderBy = rsA![OrderBy]

''设置卖出(每个,案例)

rsP!SellBy = rsA![SellBy]

''设置订单倍数

rsP!OrderMultiple = intMult

''使用供应商成本

rsP!Cost = rsP!VendCost

''从订单中使用价格

rsP!价格= rsA!价格

' '保存新的PO产品行

rsP.Update

rsP.Close

设置rsP =没有

' '更新订单状态

rsA.Edit

'把我们在订单中找到的供应商放入

rsA!VendorID = lngVendor

''设置相关的PO行号

rsA!OrderPOLineNo = intL

''在订单上标记状态"

rsA!Status = OrderStatus.OnOrder

rsA.Update

''最后,获取PO并取消设置其已完成标志

db.Execute(" Update tblPurchaseOrders" &安培; _

" Set [Completed] = False" &安培; _

" Where [PONumber] =" &安培; rsA!OrderPONo)

结束如果

结束如果

''处理退货的代码结束

Else

''处理正分配的代码开始

''数量为正 - 尝试从库存中分配

intQuantityReq = rsA!AmtNeeded

''在主库存表中查找产品

rsI.FindFirst" ProductID =" &安培; rsA!产品ID

如果不是rsI.NoMatch那么

''我们找到了库存行 - 检查可用数量

如果rsI!QuantityOnHand > 0然后

''看起来有些库存,

''所以在库存行打开一个记录集

strSQL =" Select *来自tblStock"

strSQL = strSQL& "其中[ProductID] =" &

rsA!ProductID

strSQL = strSQL& " AND QuantityRemaining> 0"

strSQL = strSQL& " ORDER BY [DateReceived]"

''Recordset首先删除最旧的行

设置rsS = db.OpenRecordset(strSQL)

如果不是rsS.EOF那么

rsS.Edit

''如果这个股票记录足够,那么......

如果intQuantityReq< = rsS!QuantityRemaining然后

''..从这个库存行中取出产品和

我们已经完成了

''添加数量需要库存分配

rsS!QuantityAllocated = rsS!QuantityAllocated +

_

intQuantityReq

''减少数量剩余数量需要

rsS!QuantityRemaining = rsS!QuantityRemaining -

_

intQuantityReq

''保存记录

rsS.Update

''全部 - 设置为零

intQuantityReq = 0

Else

''..否则,抓住可用的东西

''拿剩余的东西并将其添加到

分配

rsS!QuantityAllocated = rsS!QuantityAllocated +

_

rsS!QuantityRemaining

''减少剩余金额所需的金额

intQuantityReq = intQuantityReq - _

rsS!QuantityRemaining

''设置剩余为零

rsS!QuantityRemaining = 0

''保存记录

rsS.Update

结束如果

''节省更新订单行的成本

curCost = rsS!成本

''保存供应商ID以更新订单行

lngVendor = rsS!VendorID

rsS.Close

''我们要更新订单,所以编辑行

rsA。编辑

''使用我们在库存中找到的更新订单...

''如果剩余数量,那么这将是

''减少原始数量

rsA!AmtNeeded =(rsA!AmtNeeded - intQuantityReq)

''设置分配的成本

rsA!Cost = curCost

''设定此金额分配

rsA!Status = OrderStatus.Allocated

''设置分配日期

rsA!DateAlloc = datAllocDate

''更新供应商ID

rsA!VendorID = lngVendor

''保存订单记录

rsA.Update

''刷新主库存总额......

rsI.Edit

''在这里使用查询,以便此例程''

''将在交易中看到更新的数量

''。

设置qd = db.QueryDefs(" zqrySumStockParm")

qd!ItemToFind = rsA!ProductID

Set rst = qd.OpenRecordset()

''更新非标准化"钙值

''在库存行中。

如果不是rst.EOF那么

rsI!HighCost = rst!MaxCost

rsI!QuantityInStock = rst!可用

rsI!QuantityOnHand = rst!保持

否则

rsI!QuantityInStock = 0

rsI!QuantityOnHand = 0

结束如果

rst.Close

qd.Close

''更新库存大师

rsI.Update

结束如果

结束如果

结束如果

''查看是否剩余要分配

如果intQuantityReq> 0然后

''我们在当前行上分配了吗?

如果rsA!状态= OrderStatus.Allocated那么

''是 - 需要创建一个新行

''剩余数量!

''保存行号以取回

lngThisLine = rsA!LineNo

''为新行保存值

lngProductID = rsA!ProductID

curCost = rsA!成本

curPrice = rsA!价格

''现在,添加一个新订单行!

''这是DAO中的一个很酷的技巧 - 新行将出现

for

''在当前记录集的末尾处理,所以

我们会

''继续寻找可用其他

成本的库存记录

''我们要么分配所有要求的,要么结束

剩余

''相当于采购订单中的东西。

rsA.AddNew

intAddedSome = True

''设置订单ID

rsA!OrderID = lngOrder

''使用查询查找当前最大的行号

设置rst = db.OpenRecordset(" Select Max([LineNo] ])

MaxLine" &安培; _

"来自tblOrderProducts,其中[OrderID] =" &

lngOrder)

rsA!LineNo = rst![MaxLine] + 1

rst.Close

''设置产品ID,数量和价格

rsA!ProductID = lngProductID

rsA!Cost = curCost

rsA!Price = curPrice

rsA!AmtNeeded = intQuantityReq

rsA!Status = OrderStatus.None

''保存新订单产品行

''剩余的未分配金额

rsA.Update

''将原始行号重新定位为''

''继续处理!

rsA.FindFirst" [LineNo] =" &安培; lngThisLine

如果rsA.NoMatch那么''不应该发生!

错误3999

结束如果

结束如果

结束如果

结束如果

''已完成处理当前的订单记录 - 获取下一个

rsA。 MoveNext

intI = intI + 1

''更新状态表

varRet = SysCmd(acSysCmdUpdateMeter,intI)

循环

''完成所有订单行 - 清除状态栏

varRet = SysCmd(acSysCmdClearStatus)

''承诺我们的'已完成

CommitTrans

intTrans = False

''关闭记录集

rsA.Close

设置rsA =没什么

rsI.Close

设置rsI =没什么

rstW.Close

Set rstW = Nothing

''关闭沙漏

DoCmd.Hourglass False

''如果没有警告,那么设置返回成功

如果不是(intSomeError)那么AllocateProdu cts = True

''如果我们添加了一些订单行

If(intAddedSome = True)那么

''如果加载订单表格(它应该是,但只是检查)

如果IsFormLoaded(" frmOrders")那么

''重新查询子表单

Forms!frmOrders!fsubOrderProducts .Requery

结束如果

结束如果

''看看是否有任何未分配 - 运行追加剩余物"查询

设置qd = db.QueryDefs(" zqappOrderProductsToOrder")

qd![OrderParm] = lngOrder

qd.Execute

''查看是否有任何行

如果DCount(*,ztTblProductsToOrder)<> 0然后

''是 - 设置一个标志

intSomeLeft = True

''询问用户是否想要创建采购订单

''但是如果从zfrmLoadData调用则自动创建PO

如果intSilent然后

intDoPO = vbYes

否则

intDoPO = MsgBox(库存中的库存不足一个& _

或此订单所需的更多产品。& _

是否要为此订单生成采购订单?,_

vbQuestion + vbYesNo,gstrAppTitle)

结束如果

如果intDoPO = vbYes那么

''关闭本地错误陷阱

错误转到0

''调用产品PO生成器 - 通过沉默的旗帜

如果是GenProductsPO(lngOrder,intSilent,datAllocDate)那么

''表示创建的购买订单

AllocateProducts = 1

intSomeLeft = False

结束如果

结束如果

结束如果
if(intSomeLeft = True)然后

如果不是intSilent那么MsgBox没有分配一些产品, &

_

"但你取消了PO创建。",vbInformation,gstrAppTitle

结束如果


''让DBEngine赶上所有这些工作

DBEngine.Idle dbFreeLocks


''完成

退出函数


AllocOrderProducts_ERR:

''显示并记录任何错误

如果不是intSilent那么MsgBox"意外错误: " &安培; Err& _

"," &安培;错误,vbCritical,gstrAppTitle

ErrorLog" AllocateProducts",Err,错误

On Error Resume Next

''如果交易已启动, roll it back

If (intTrans = True) Then Rollback

'' Clear the status bar

varRet = SysCmd(acSysCmdClearStatus)

'' Turn off the hourglass

DoCmd.Hourglass False

'' Bail!

Exit Function


End Function


End Sub


"Allen Browne" <铝********* @ SeeSig.Invalid> wrote in message

news:44***********************@per-qv1-newsreader-01.iinet.net.au...

We need to know a bit more about the procedure that fails.

It it includes this line:
Set rs = db.OpenRecordset("SomeTable")
try:
Set rs = db.OpenRecordset("SomeTable", dbOpenDynaset)

If that does not work, post the line that fails, and any line like the one
above.

OpenRecordset defaults to a Dynaset type for attached tables, but to a
Table type for local tables. If that is the issue, then declaring the
Dynaset type should solve the "operation is not supported for this type of
object" error.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"royaltiger" <sg*****@ntlworld.com> wrote in message
news:yt*******************@newsfe2-win.ntli.net...

I am trying to copy the inventory database in Building Access Applications
by John L Viescas but when i try to run the database i get an error in the
orders form when i click on the allocate button "Unexpected Error":3251
operation is not supported for this type of object.The demo cd has two
databases, one is called inventory and the other just has the tables for
the design called inventory data. When you run inventory the database
works fine so i thought i would use the tables in the "data" and then
import the queries and forms from the inventory, everything works fine
until i want to allocate products to a customer, i have compared tables in
both databases and they are exact except that the inventory is a linked
database, this is what i think is the problem and the table itself is the
tblInventory. Is there a few people out there who have the book and know
what i am doing wrong or know what to do to make it right




I am trying to copy the inventory database in Building Access Applications
by John L Viescas but when i try to run the database i get an error in the
orders form when i click on the allocate button "Unexpected Error":3251
operation is not supported for this type of object.The demo cd has two
databases, one is called inventory and the other just has the tables for the
design called inventory data. When you run inventory the database works fine
so i thought i would use the tables in the "data" and then import the
queries and forms from the inventory, everything works fine until i want to
allocate products to a customer, i have compared tables in both databases
and they are exact except that the inventory is a linked database, this is
what i think is the problem and the table itself is the tblInventory. Is
there a few people out there who have the book and know what i am doing
wrong or know what to do to make it right

解决方案

We need to know a bit more about the procedure that fails.

It it includes this line:
Set rs = db.OpenRecordset("SomeTable")
try:
Set rs = db.OpenRecordset("SomeTable", dbOpenDynaset)

If that does not work, post the line that fails, and any line like the one
above.

OpenRecordset defaults to a Dynaset type for attached tables, but to a Table
type for local tables. If that is the issue, then declaring the Dynaset type
should solve the "operation is not supported for this type of object" error.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"royaltiger" <sg*****@ntlworld.com> wrote in message
news:yt*******************@newsfe2-win.ntli.net...

I am trying to copy the inventory database in Building Access Applications
by John L Viescas but when i try to run the database i get an error in the
orders form when i click on the allocate button "Unexpected Error":3251
operation is not supported for this type of object.The demo cd has two
databases, one is called inventory and the other just has the tables for
the design called inventory data. When you run inventory the database works
fine so i thought i would use the tables in the "data" and then import the
queries and forms from the inventory, everything works fine until i want to
allocate products to a customer, i have compared tables in both databases
and they are exact except that the inventory is a linked database, this is
what i think is the problem and the table itself is the tblInventory. Is
there a few people out there who have the book and know what i am doing
wrong or know what to do to make it right



This is the code in the "on click procedure" of the allocate button, there
is also an AllocateProducts function placed in a module if this helps also.
Thanks for trying
Private Sub cmdAllocate_Click()
Dim intReturn As Integer, db As DAO.Database, qdA As DAO.QueryDef, rsA As
DAO.Recordset
'' User has requested to allocate / order products
'' Set local error trap while trying to put focus back
On Error Resume Next
Screen.PreviousControl.SetFocus
'' Set error trap
On Error GoTo cmdAllocate_ERR
'' Make sure the last edit is saved
If Not SaveIt() Then Exit Sub
'' Point to this database
Set db = DBEngine(0)(0)
'' Get the query that find products Status = None
Set qdA = db.QueryDefs("zqryOrderProductSelect")
'' Set the parameter for this order
qdA![OrderParm] = CLng(Me.Parent!OrderID)
'' See if records found
Set rsA = qdA.OpenRecordset()
'' If none, tell them and exit
If rsA.RecordCount = 0 Then
MsgBox "Nothing to allocate.", vbInformation, gstrAppTitle
rsA.Close
Set rsA = Nothing
Exit Sub
End If
rsA.Close
Set rsA = Nothing
'' Call the allocate function and pass it this order ID
intReturn = AllocateProducts(CLng(Me.Parent!OrderID))
'' Check the return value
Select Case intReturn
'' True = All OK
Case -1
'' Requery myself to show updated status
Me.Requery
MsgBox "Products allocation completed successfully!",
vbInformation, gstrAppTitle
'' False return - some error occurred
Case 0
MsgBox "An error occurred while attempting to allocate Products
for this " & _
"order.", vbExclamation, gstrAppTitle
'' 1 = allocated, but built some Purchase Orders
Case 1
MsgBox "Not all Products were in inventory. One or more
purchase orders " & _
"were generated.", vbInformation, gstrAppTitle
End Select

cmdAllocate_Exit:
Exit Sub

cmdAllocate_ERR:
Dim lngErr As Long, strError As String
lngErr = Err
strError = Error
ErrorLog Me.Name & "_cmdAllocate", lngErr, strError
MsgBox "Unexpected error: " & lngErr & ", " & strError & " has been
logged.", _
vbCritical, gstrAppTitle
Resume cmdAllocate_Exit

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:44***********************@per-qv1-newsreader-01.iinet.net.au...

We need to know a bit more about the procedure that fails.

It it includes this line:
Set rs = db.OpenRecordset("SomeTable")
try:
Set rs = db.OpenRecordset("SomeTable", dbOpenDynaset)

If that does not work, post the line that fails, and any line like the one
above.

OpenRecordset defaults to a Dynaset type for attached tables, but to a
Table type for local tables. If that is the issue, then declaring the
Dynaset type should solve the "operation is not supported for this type of
object" error.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"royaltiger" <sg*****@ntlworld.com> wrote in message
news:yt*******************@newsfe2-win.ntli.net...

I am trying to copy the inventory database in Building Access Applications
by John L Viescas but when i try to run the database i get an error in the
orders form when i click on the allocate button "Unexpected Error":3251
operation is not supported for this type of object.The demo cd has two
databases, one is called inventory and the other just has the tables for
the design called inventory data. When you run inventory the database
works fine so i thought i would use the tables in the "data" and then
import the queries and forms from the inventory, everything works fine
until i want to allocate products to a customer, i have compared tables in
both databases and they are exact except that the inventory is a linked
database, this is what i think is the problem and the table itself is the
tblInventory. Is there a few people out there who have the book and know
what i am doing wrong or know what to do to make it right




This is the AllocateProducts function placed in a module called
modInventory.
Option Compare Database ''Use database order for string comparisons
Option Explicit
Dim mlngLineNum As Long, mlngErr As Long, mstrError As String

Function AllocateProducts(lngOrder As Long, _
Optional intSilent As Integer = 0, _
Optional varDate As Variant) As Integer
''
'' Inputs: Order ID
'' Optional "run silent" indicator (used by zfrmLoadData)
'' Optional process date (used by zfrmLoadData)
''
'' Output: Returns "True" (-1) if all Products allocated successfully
'' Returns +1 if Products allocated and purchase order(s) generated
'' Returns "False" (0) if an error occurs
''
'' Technique:
'' This routine attempts to allocate the required Products.
'' Uses "zqryOrderProductSelect" to find Products where Status not
'' On Order, Allocated, or Invoiced. If Product is being returned
(negative
'' quantity), posts to Inventory or the original PO as appropriate.
'' If Product is being ordered (positive quantity), allocates from stock
'' in inventory. At end of allocation if some still not allocated from
'' inventory, then stuffs the unordered Products in ztTblProductsToOrder
'' and calls the common PO build routine.
''
'' Note: When called from zfrmLoadData, intSilent is True - procedure will
'' open no forms and will not display any errors. zfrmLoadData also
'' passes the date it wants to use as the allocation / PODate date.
''
Dim db As DAO.Database, qd As DAO.QueryDef, qdA As DAO.QueryDef
Dim rsA As DAO.Recordset, rsI As DAO.Recordset, rsS As DAO.Recordset
Dim rst As DAO.Recordset, rsP As DAO.Recordset, rsC As DAO.Recordset
Dim varQuantity As Variant, intQuantityReq As Integer
Dim varRet As Variant, intEditA As Integer, intRecCount As Integer
Dim intI As Integer, intSomeError As Integer, intSomeLeft As Integer
Dim intCount As Integer, intQty As Integer, intMult As Integer
Dim intL As Integer, curMinPrice As Currency, curCost As Currency
Dim curPrice As Currency, varCost As Variant, varPrice As Variant
Dim lngPO As Long, lngVendor As Long, intTrans As Integer
Dim lngProductID As Long, lngThisLine As Long, intAddedSome As Integer
Dim intDoPO As Integer, datAllocDate As Date, lngVend As Long
Dim rstW As DAO.Recordset, strSQL As String, strMsg As String

On Error Resume Next
'' Set up for default false return
AllocateProducts = 0

'' Set up the allocation date
datAllocDate = Date
'' If passed a date variable
If Not IsMissing(varDate) Then
'' .. and it''s a valid date
If IsDate(varDate) Then
'' Use the parameter value
datAllocDate = varDate
End If
End If

'' Point to this database
Set db = DBEngine(0)(0)
'' Open the Order and lock it!
Set rstW = db.OpenRecordset("Select OrderID From tblOrders " & _
"Where OrderID = " & lngOrder)
If rstW.EOF Then
If Not intSilent Then
MsgBox "Unexpected error: Can''t find Order #" & _
lngOrder, vbCritical, gstrAppTitle
End If
Exit Function
End If
'' Lock the order by editing it
rstW.Edit
If Err <> 0 Then
strMsg = "Error trying to edit Order #" & lngOrder
strMsg = strMsg & ". Someone else may be editing this Order."
If Not intSilent Then MsgBox strMsg, vbExclamation, gstrAppTitle
Exit Function
End If

'' Set an error trap
On Error GoTo AllocOrderProducts_ERR

'' Clean out working table to store Products not in stock
db.Execute "Delete * FROM zttblProductsToOrder;", dbFailOnError

'' Turn on the hourglass and start a transaction
DoCmd.Hourglass True
BeginTrans
intTrans = True

'' Open a recordset on Products to allocate
Set qdA = db.QueryDefs("zqryOrderProductSelect")
qdA![OrderParm] = lngOrder
Set rsA = qdA.OpenRecordset()
'' Open the inventory table
Set rsI = db.OpenRecordset("tblInventory")

'' Get count of Products to allocate rows for SysCmd
rsA.MoveLast
intRecCount = rsA.RecordCount
rsA.MoveFirst

'' Show a progress meter
varRet = SysCmd(acSysCmdInitMeter, "Updating Inventory...", intRecCount)

'' Loop through all Products to allocate, deduct from stock,
'' and adjust master Inventory row
Do Until rsA.EOF
'' If returning products, ...
If rsA![AmtNeeded] < 0 Then
'' See if return is to a Purchase Order
If IsNothing(rsA!OrderPONo) Then
'' If no PO to credit, then return to inventory
intQty = rsA![AmtNeeded]
'' Find the inventory record
rsI.FindFirst "ProductID = " & rsA!ProductID
If rsI.NoMatch Then
'' Ooops -- can''t find the inventory record to return
'' the Product!
intSomeError = True
strMsg = "Error attempting to return Product # "
strMsg = strMsg & rsA!ProductID & " to inventory."
strMsg = strMsg & " Inventory record not found."
strMsg = strMsg & " The Order record has been deleted."
If Not intSilent Then MsgBox strMsg, _
vbCritical, gstrAppTitle
'' Delete the Order row
rsA.Delete
Else
'' Found the Inventory row - edit it to lock it
rsI.Edit
'' Find the matching Stock row for an inventory return
strSQL = "Select * From tblStock Where ([ProductID] = "
strSQL = strSQL & rsA!ProductID
strSQL = strSQL & ") And ([Cost] = " & rsA!Cost & ")"
'' If there''s a VendorID, then also filter for vendor
If Not IsNothing(rsA!VendorID) Then
strSQL = strSQL & " AND ([VendorID] = " & _
rsA!VendorID & ")"
lngVendor = rsA!VendorID
End If
'' Open the Stock recordset
Set rsS = db.OpenRecordset(strSQL)
If rsS.EOF Then
'' Ooops -- can''t find the stock row to return
'' the Product!
intSomeError = True
strMsg = "Error attempting to return Product # "
strMsg = strMsg & rsA!ProductID & " to stock."
strMsg = strMsg & " Stock record that matches the "
strMsg = strMsg & "vendor and cost not found."
strMsg = strMsg & " The Order record has been
deleted."
If Not intSilent Then MsgBox strMsg, _
vbCritical, gstrAppTitle
'' Delete the Order row
rsA.Delete
Else
'' Return the Products to the Stock record
rsS.Edit
'' Subtract from Allocated amount -
'' product now available back in stock
'' NOTE: QuantityAllocated can be negative if
'' previously allocated product was already
'' invoiced. Will correct when invoiced item
credited.
rsS!QuantityAllocated = rsS!QuantityAllocated + _
rsA!AmtNeeded
rsS!QuantityRemaining = rsS!Quantity - _
(rsS!QuantityAllocated + rsS!QuantitySold + _
rsS!QuantityReturned)
lngVendor = rsS!VendorID
rsS.Update
intQuantityReq = 0
End If
rsS.Close
'' Refresh the master inventory totals...
rsI.Edit
'' Using a query here so that this routine will
'' see the updated quantities within the transaction.
Set qd = db.QueryDefs("zqrySumStockParm")
qd!ItemToFind = rsA!ProductID
Set rst = qd.OpenRecordset()
'' Update the calc values in the Inventory row.
If Not rst.EOF Then
rsI!HighCost = rst!MaxCost
rsI!QuantityInStock = rst!Available
rsI!QuantityOnHand = rst!Remain
Else
rsI!QuantityInStock = 0
rsI!QuantityOnHand = 0
End If
rst.Close
Set rst = Nothing
qd.Close
Set qd = Nothing
rsI.Update

'' Update the Order status
rsA.Edit
rsA!Status = OrderStatus.Allocated
rsA!DateAlloc = datAllocDate
rsA!VendorID = lngVendor
rsA.Update
End If
Else
'' There''s a PO Number, so credit back to the PO!
'' Open a recordset on PO Products to insert the row
Set rsP = db.OpenRecordset("zqryPOProductsForAlloc", _
dbOpenDynaset, dbAppendOnly)
'' Insert a new PO Product row to queue up the credit
'' Get "next" line no --
'' must use recordset inside a transaction!
Set rsC = db.OpenRecordset("Select Max([LineNo]) As
[LastLineNo] " & _
"From tblPOProducts " & _
"Where [PONumber] = " & rsA!OrderPONo)
If IsNull(rsC!LastLineNo) Then
intL = 1
Else
intL = rsC!LastLineNo + 1
End If
rsC.Close
rsP.AddNew
rsP!PONumber = rsA!OrderPONo
'' Setting the PO Number should "autolookup"
'' the Vendor ID from the PO
If IsNothing(rsP!POVend) Then
'' Ooops - means the PO does not exist!
If Not intSilent Then
MsgBox "Error attempting to credit product # " & _
rsA!ProductID & " to purchase order # " &
rsA!OrderPONo & _
". The Purchase Order cannot be found. " & _
"The PO Number in the Order has been zeroed.", _
vbCritical, gstrAppTitle
End If
intSomeError = True
rsA.Edit
'' Zero out the PO Number
rsA!OrderPONumber = 0
rsA.Update
'' Discard the POProduct row
rsP.Close
Set rsP = Nothing
Else
'' OK - have a good PO, so set the rest of the fields
rsP!LineNo = intL
'' copy Vendor ID from the Purchase Order
rsP!VendorID = rsP!POVend
lngVendor = rsP!POVend
'' Copy the Product ID
rsP!ProductID = rsA!ProductID
'' Save the quantity required
intQty = rsA![AmtNeeded]
'' .. and the order multiple
'' (number of sell units in one purchase unit)
intMult = rsA![OrderMultiple]
'' Set the return quantity
rsP!SellQuantity = intQty
'' If the quantity is an even multiple
If intQty Mod intMult = 0 Then
'' Do an integer divide to get the amount to order
rsP!BuyQuantity = intQty \ intMult
Else
'' else round up to the next buy amount
rsP!BuyQuantity = (intQty \ intMult) + 1
End If
'' Set the order by ("case", "pallet")
rsP!OrderBy = rsA![OrderBy]
'' Set the sell by ("each", "case")
rsP!SellBy = rsA![SellBy]
'' Set the order multiple
rsP!OrderMultiple = intMult
'' Use the vendor cost
rsP!Cost = rsP!VendCost
'' Use price from the order
rsP!Price = rsA!Price
'' Save the new PO Product row
rsP.Update
rsP.Close
Set rsP = Nothing
'' Update the Order status
rsA.Edit
'' Put the vendor we found in the order
rsA!VendorID = lngVendor
'' Set the related PO line number
rsA!OrderPOLineNo = intL
'' Mark the status "on order"
rsA!Status = OrderStatus.OnOrder
rsA.Update
'' Finally, get the PO and unset its Completed flag
db.Execute ("Update tblPurchaseOrders " & _
"Set [Completed] = False " & _
"Where [PONumber] = " & rsA!OrderPONo)
End If
End If
'' End of code to process returns
Else
'' Start of code to process positive allocations
'' Quantity is positive -- go try to allocate from inventory
intQuantityReq = rsA!AmtNeeded
'' Find the Product in the master inventory table
rsI.FindFirst "ProductID = " & rsA!ProductID
If Not rsI.NoMatch Then
'' We found the inventory row -- check for quantity available
If rsI!QuantityOnHand > 0 Then
'' Looks like some in stock,
'' so open a recordset on the stock rows
strSQL = "Select * From tblStock"
strSQL = strSQL & " Where [ProductID] = " &
rsA!ProductID
strSQL = strSQL & " AND QuantityRemaining > 0"
strSQL = strSQL & " ORDER BY [DateReceived]"
'' Recordset plucks off the oldest rows first
Set rsS = db.OpenRecordset(strSQL)
If Not rsS.EOF Then
rsS.Edit
'' If this stock record has enough, then ...
If intQuantityReq <= rsS!QuantityRemaining Then
'' .. pluck the Products from this stock row and
we''re done
'' Add the quantity needed to Stock Allocated
rsS!QuantityAllocated = rsS!QuantityAllocated +
_
intQuantityReq
'' Reduce quantity remaining by quantity needed
rsS!QuantityRemaining = rsS!QuantityRemaining -
_
intQuantityReq
'' Save the record
rsS.Update
'' Got it all - set required to zero
intQuantityReq = 0
Else
'' .. otherwise, grab what''s available
'' Take whatever is remaining and add it to
allocated
rsS!QuantityAllocated = rsS!QuantityAllocated +
_
rsS!QuantityRemaining
'' Reduce required by amount that was remaining
intQuantityReq = intQuantityReq - _
rsS!QuantityRemaining
'' Set remaining to zero
rsS!QuantityRemaining = 0
'' Save the record
rsS.Update
End If
'' Save the cost for updating the Order row
curCost = rsS!Cost
'' Save the vendor ID for updating the Order row
lngVendor = rsS!VendorID
rsS.Close
'' We''re going to update the Order, so edit the row
rsA.Edit
'' Update the Order with what we found in stock...
'' If quantity remaining, then this will
'' reduce the original quantity
rsA!AmtNeeded = (rsA!AmtNeeded - intQuantityReq)
'' Set in the allocated found cost
rsA!Cost = curCost
'' Set this amount allocated
rsA!Status = OrderStatus.Allocated
'' Set the allocation date
rsA!DateAlloc = datAllocDate
'' Update the Vendor ID
rsA!VendorID = lngVendor
'' Save the Order record
rsA.Update
'' Refresh the master inventory totals...
rsI.Edit
'' Using a query here so that this routine ''
'' will see the updated quantities
'' within the transaction.
Set qd = db.QueryDefs("zqrySumStockParm")
qd!ItemToFind = rsA!ProductID
Set rst = qd.OpenRecordset()
'' Update the "unnormalized" calc values
'' in the Inventory row.
If Not rst.EOF Then
rsI!HighCost = rst!MaxCost
rsI!QuantityInStock = rst!Available
rsI!QuantityOnHand = rst!Remain
Else
rsI!QuantityInStock = 0
rsI!QuantityOnHand = 0
End If
rst.Close
qd.Close
'' Update the inventory master
rsI.Update
End If
End If
End If
'' See if any remaining to allocate
If intQuantityReq > 0 Then
'' Did we allocate any on the current row?
If rsA!Status = OrderStatus.Allocated Then
'' Yes - need to create a new row
'' with remaining quantity!
'' Save the line number to get back
lngThisLine = rsA!LineNo
'' Save values for new row
lngProductID = rsA!ProductID
curCost = rsA!Cost
curPrice = rsA!Price
'' Now, add a new Order row!
'' This is a cool trick in DAO - the new row will come up
for
'' processing at the end of the current recordset, so
we''ll
'' keep looking for available Stock records at other
costs until
'' we either allocate all requested or end up with a
left over
'' amount to stuff in a Purchase Order.
rsA.AddNew
intAddedSome = True
'' Set the order ID
rsA!OrderID = lngOrder
'' Use a query to find the current largest line number
Set rst = db.OpenRecordset("Select Max([LineNo]) As
MaxLine " & _
"From tblOrderProducts Where [OrderID] = " &
lngOrder)
rsA!LineNo = rst![MaxLine] + 1
rst.Close
'' Set up Product ID, quantity, and prices
rsA!ProductID = lngProductID
rsA!Cost = curCost
rsA!Price = curPrice
rsA!AmtNeeded = intQuantityReq
rsA!Status = OrderStatus.None
'' Save the new Order Products row with
'' remaining unallocated amount
rsA.Update
'' Reposition on the original line number to ''
'' continue processing!
rsA.FindFirst "[LineNo] = " & lngThisLine
If rsA.NoMatch Then '' Should not occur!
Error 3999
End If
End If
End If
End If
'' Finished processing the current Order record - get the next
rsA.MoveNext
intI = intI + 1
'' Update the status meter
varRet = SysCmd(acSysCmdUpdateMeter, intI)
Loop
'' Done with all Order rows - clear the status bar
varRet = SysCmd(acSysCmdClearStatus)
'' Commit what we''ve done
CommitTrans
intTrans = False
'' Close off recordsets
rsA.Close
Set rsA = Nothing
rsI.Close
Set rsI = Nothing
rstW.Close
Set rstW = Nothing
'' Turn off the hourglass
DoCmd.Hourglass False
'' If got no warnings, then set up to return success
If Not (intSomeError) Then AllocateProducts = True
'' If we added some Order rows
If (intAddedSome = True) Then
'' If Order form loaded (it should be, but just checking)
If IsFormLoaded("frmOrders") Then
'' Requery the subform
Forms!frmOrders!fsubOrderProducts.Requery
End If
End If
'' See if any left unallocated - run the "append leftovers" query
Set qd = db.QueryDefs("zqappOrderProductsToOrder")
qd![OrderParm] = lngOrder
qd.Execute
'' See if there are any rows
If DCount("*", "ztTblProductsToOrder") <> 0 Then
'' Yes - set a flag
intSomeLeft = True
'' Ask if user wants to create Purchase Orders
'' But auto-create PO if called from zfrmLoadData
If intSilent Then
intDoPO = vbYes
Else
intDoPO = MsgBox("Insufficient stock in inventory for one " & _
"or more Products required for this order. " & _
"Do you want to generate purchase orders for this order?", _
vbQuestion + vbYesNo, gstrAppTitle)
End If
If intDoPO = vbYes Then
'' Turn off local error trapping
On Error GoTo 0
'' Call the Product PO generator - pass the silent flag
If GenProductsPO(lngOrder, intSilent, datAllocDate) Then
'' Indicate Purchase Orders created
AllocateProducts = 1
intSomeLeft = False
End If
End If
End If
If (intSomeLeft = True) Then
If Not intSilent Then MsgBox "Some Products were not allocated, " &
_
"but you cancelled PO creation.", vbInformation, gstrAppTitle
End If

'' Let the DBEngine catch up with all this work
DBEngine.Idle dbFreeLocks

'' Done
Exit Function

AllocOrderProducts_ERR:
'' Display and log any errors
If Not intSilent Then MsgBox "Unexpected Error: " & Err & _
", " & Error, vbCritical, gstrAppTitle
ErrorLog "AllocateProducts", Err, Error
On Error Resume Next
'' If a transaction was started, roll it back
If (intTrans = True) Then Rollback
'' Clear the status bar
varRet = SysCmd(acSysCmdClearStatus)
'' Turn off the hourglass
DoCmd.Hourglass False
'' Bail!
Exit Function

End Function

End Sub

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:44***********************@per-qv1-newsreader-01.iinet.net.au...

We need to know a bit more about the procedure that fails.

It it includes this line:
Set rs = db.OpenRecordset("SomeTable")
try:
Set rs = db.OpenRecordset("SomeTable", dbOpenDynaset)

If that does not work, post the line that fails, and any line like the one
above.

OpenRecordset defaults to a Dynaset type for attached tables, but to a
Table type for local tables. If that is the issue, then declaring the
Dynaset type should solve the "operation is not supported for this type of
object" error.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"royaltiger" <sg*****@ntlworld.com> wrote in message
news:yt*******************@newsfe2-win.ntli.net...

I am trying to copy the inventory database in Building Access Applications
by John L Viescas but when i try to run the database i get an error in the
orders form when i click on the allocate button "Unexpected Error":3251
operation is not supported for this type of object.The demo cd has two
databases, one is called inventory and the other just has the tables for
the design called inventory data. When you run inventory the database
works fine so i thought i would use the tables in the "data" and then
import the queries and forms from the inventory, everything works fine
until i want to allocate products to a customer, i have compared tables in
both databases and they are exact except that the inventory is a linked
database, this is what i think is the problem and the table itself is the
tblInventory. Is there a few people out there who have the book and know
what i am doing wrong or know what to do to make it right




这篇关于构建访问应用程序“库存”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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