访问2003表单/子表单中的VBA问题 [英] VBA Problems within An access 2003 form/Subform

查看:82
本文介绍了访问2003表单/子表单中的VBA问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在使用xp sp2在Access 2003中为我的公司制作数据库。我创建了一个包含子表单的订单表单。订单表格(父订单(链接到订单Qry))和订单子订单(子订单(链接到订单详细信息扩展Qry)。


这类似于订单表格Northwind,好的,它几乎相同的标识我选择公司名称并提取他们的详细信息,在主窗体中选择一个客户端。在Subform我应该选择一个产品并输入订购的数量。但是当我选择第二个产品我得到以下vba错误:


编译错误:Sub或Function未定义..


继承代码:


私有子Form_BeforeUpdate(取消为整数)

''如果订单子表单作为独立表单打开,则显示消息

''并撤消对ProductName文本框所做的更改。(IsLoaded函数

''在Forms集合中单独打开时找到一个表单

''形式,但不是当它作为一个子表格打开时主要形式。)


Dim strMsg As String,strTitle As String

Dim intStyle As Integer


If IsLoaded (Orders Subform)然后

strMsg ="当您将Orders Subform作为独立表单打开时,您不能添加或编辑记录。

intStyle = vbOKOnly

strTitle ="不能添加或更改记录"

MsgBox strMsg,intStyle,strTitle

Me.Undo

结束如果


结束子


IsLoaded部分突出显示。


现在我买了3本关于Access的书,并在访问中使用VBA,但我还没有找到解决方案:(

Hi,

Im making a db for my company in Access 2003 usin xp sp2. Ive created an orders form that has a subform in it. The Order form (parent(is linked to a Orders Qry)) and the Orders Subform (Child(is linked to Order Details Extended Qry).

This works similar to the Orders form in Northwind, ok ok its pretty much identitcal What happens is i select a client in the main form by selecting the company name and that pulls up their details. In the Subform im supposed to select a product and enter the quantity being ordered. However when i select a 2nd product i get the following vba error:

Compile error: Sub or Function not defined..

Heres the code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
'' If Orders Subform is opened as a standalone form, display a message
'' and undo changes made to the ProductName text box. (The IsLoaded function
'' finds a form in the Forms collection when it''s opened as a standalone
'' form, but not when it''s opened as a subform on a main form.)

Dim strMsg As String, strTitle As String
Dim intStyle As Integer

If IsLoaded("Orders Subform") Then
strMsg = "You can''t add or edit a record when you open Orders Subform as a standalone form."
intStyle = vbOKOnly
strTitle = "Can''t Add or Change Record"
MsgBox strMsg, intStyle, strTitle
Me.Undo
End If

End Sub

the IsLoaded part gets highlighted.

Now ive bought 3 books on Access, and using VBA in access, but i havent been able to find a solution yet :(

推荐答案

确定添加
OK add
展开 | S选举 | Wrap | 行号


在模块中或您希望的表单代码中!
In module or in your form code as you want!


OH

我的

上帝


我爱你:D你知道知道多长时间这令我感到沮丧!!!!


< 3
OH
MY
GOD

I LOVE YOU :D you know know how long that was frustrating me for!!!!

<3


这篇关于访问2003表单/子表单中的VBA问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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