表格不会进入新纪录 [英] Form Doesn't Go To New Record

查看:87
本文介绍了表格不会进入新纪录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表格大约有25个字段。在表单的BeforeUpdate事件中,我
具有将每个字段的默认值设置为其当前值的代码。对于

新记录,我可以把重点放在任何领域开始。如果我编辑该字段并且

然后单击导航按钮中的新记录按钮,表单将转到

a新记录,并且每个字段都具有以前的默认值记录。如果我

将焦点放在任何字段中开始,编辑该字段转到任何其他字段并且

编辑它,当我点击导航中的新记录按钮时按钮

表单不会转到新记录。我必须点击新记录按钮一秒钟才能获得新记录。我也试过把代码设置为

的默认值表格的AfterUpdate事件,我遇到了必须在新记录按钮上点击两次

的相同问题。


有没有人想到可能导致这种行为的原因?


谢谢!


Steve

I have a form with about 25 fields. In the BeforeUpdate event of the form, I
have code that sets the default value of each field to its current value. For a
new record, I can put the focus in any field to start. If I edit that field and
then click on the new record button in the navigation buttons, the form goes to
a new record and each field has the default value of the previous record. If I
put the focus in any field to start, edit that field go to any other field and
edit it, when I click on the new record button in the navigation buttons the
form does not go to a new record. I have to click the new record button a second
time to go to a new record. I also tried putting the code to set the defaults in
the AfterUpdate event of the form and I get the same problem of having to click
on the new record button twice.

Does anyone have any thoughts as to what may be causing this behaviour?

Thanks!

Steve

推荐答案

" Steve" < SP ** @ nospam.spam>在消息中写道

news:gi ***************** @ newsread3.news.atl.earthl ink.net
"Steve" <sp**@nospam.spam> wrote in message
news:gi*****************@newsread3.news.atl.earthl ink.net
我的表格有大约25个字段。在
表单的BeforeUpdate事件中,我有代码将每个字段的默认值设置为其当前值。对于新的记录,我可以把焦点放在任何领域来开始。如果我编辑该字段然后单击导航按钮中的新记录按钮
,则表单将转到新记录,并且每个
字段都具有上一记录的默认值。如果我把
焦点放在任何一个字段中开始,编辑该字段转到任何其他字段
并编辑它,当我点击导航中的新记录按钮
按钮时表单确实如此没有去新的记录。我必须再次点击新的
记录按钮才能转到新记录。我也尝试过把代码设置为
表单的AfterUpdate事件中的默认值,我也遇到了两次点击新记录
按钮的问题。

有没有人想过可能导致这种行为的原因?

谢谢!

史蒂夫
I have a form with about 25 fields. In the BeforeUpdate event of the
form, I have code that sets the default value of each field to its
current value. For a new record, I can put the focus in any field to
start. If I edit that field and then click on the new record button
in the navigation buttons, the form goes to a new record and each
field has the default value of the previous record. If I put the
focus in any field to start, edit that field go to any other field
and edit it, when I click on the new record button in the navigation
buttons the form does not go to a new record. I have to click the new
record button a second time to go to a new record. I also tried
putting the code to set the defaults in the AfterUpdate event of the
form and I get the same problem of having to click on the new record
button twice.

Does anyone have any thoughts as to what may be causing this
behaviour?

Thanks!

Steve




我想你最好发布表格背后的代码。


-

Dirk Goldgar,MS Access MVP
www.datagnostics.com


(请回复新闻组)



I think you''d better post the code behind the form.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Private Sub Form_BeforeUpdate(取消为整数)

Dim Ctrl As Control

对于每个Ctrl In Me.Controls

如果Ctrl.ControlType<> acLabel和Ctrl.ControlType<> acCommandButton然后

如果不是IsNull(Ctrl.Value)那么

如果是InStr(Ctrl.Value,vbCrLf)> 0然后

MsgBox Ctrl.Controls(0).Caption& "包含A Line Return。 &安培; vbCrLf&

vbCrLf _

& 新项目无法保存在数据库中 &安培; vbCrLf _

& 直到删除换行符。 &安培; vbCrLf& vbCrLf _

& 请删除该行返回!

取消=真

Ctrl.SetFocus

退出子

结束如果

结束如果

结束如果

下一步


''使用BeforeUpdate事件为此所以InvNumber = StoreItemID当项目

被保存

我!InvNumber =我!StoreItemID

如果我!SetThisItemAsTheDefaultNewItem = True然后

调用SetDefaultValues

否则

调用RemoveDefaultValues

结束如果

我!标题。 SetFocus

结束子


Public Sub SetDefaultValues()

错误GoTo ErrorHandler

我! Title.DefaultValue = CQuote&我!标题& CQuote

Me!FeatureFlag.DefaultValue = CQuote&我!FeatureFlag& CQuote

Me!ShortDesc.DefaultValue = CQuote&我!ShortDesc& CQuote

Me!Description.DefaultValue = CQuote&我!描述& CQuote

Me!ThumbImage.DefaultValue = CQuote&我!ThumbImage& CQuote

Me!FullImage.DefaultValue = CQuote&我!FullImage& CQuote


如果不是IsNull(我!类别)那么

Me!Category.DefaultValue = CQuote&我!类别& CQuote

Else

Me!Category.DefaultValue =""

结束如果

如果不是IsNull(我!部分)然后

我!Section.DefaultValue = CQuote&我!部分& CQuote

Else

Me!Section.DefaultValue =""

结束如果

如果不是IsNull(我!过道)然后

我!Aisle.DefaultValue = CQuote&我!过道& CQuote

Else

Me!Aisle.DefaultValue =""

结束如果


我!Alt1.DefaultValue = CQuote&我!Alt1& CQuote

Me!Alt2.DefaultValue = CQuote&我!Alt2& CQuote

Me!Alt3.DefaultValue = CQuote&我!Alt3& CQuote

Me!ListValue.DefaultValue = CQuote&我!ListValue& CQuote

Me!SalePrice.DefaultValue = CQuote&我!SalePrice& CQuote

Me!SellingPrice.DefaultValue = CQuote&我!销售价格& CQuote

Me!DatePurchased.DefaultValue = CQuote&我!DatePurchased& CQuote

Me!ItemCost.DefaultValue = CQuote&我!ItemCost& CQuote

Me!ShipCost.DefaultValue = CQuote&我!ShipCost& CQuote


如果不是IsNull(Me!InventoryLocation)那么

Me!InventoryLocation.DefaultValue = CQuote&我!InventoryLocation& CQuote

Else

Me!InventoryLocation.DefaultValue =""

结束如果


我!Inventory.DefaultValue = CQuote&我!库存& CQuote

Me!ReorderPoint.DefaultValue = CQuote&我!ReorderPoint& CQuote

Me!Quantity.DefaultValue = CQuote&我!数量& CQuote

ExitHere:

Me!Title.SetFocus

退出Sub

ErrorHandler:

MsgBox Err.Description,Error# &安培; Err.Number

恢复退出这里

结束子


Public Sub RemoveDefaultValues()

我! Title.DefaultValue =""

Me!FeatureFlag.DefaultValue =""

Me!ShortDesc.DefaultValue =""

Me!Description.DefaultValue =""

Me!ThumbImage.DefaultValue =""

Me!FullImage.DefaultValue =""

Me!Category.DefaultValue =""

Me!Section.DefaultValue =""

Me!Aisle.DefaultValue ="

Me!Alt1.DefaultValue =""

Me!Alt2.DefaultValue =""

Me!Alt3。 DefaultValue =""

Me!ListValue.DefaultValue =""

Me!SalePrice.DefaultValue =""

我!SellingPrice.DefaultValue =""

Me!DatePurchased.DefaultValue =""

Me!ItemCost.DefaultValue =""

我!ShipCost。 DefaultValue =""

Me!InventoryLocation.DefaultValue =""

Me!Inventory.DefaultValue =""

我!ReorderPoint.DefaultValue =""

Me!Quantity.DefaultValue =""

End Sub


Dirk Goldgar < dg@NOdataSPAMgnostics.com>在消息中写道

news:Oa ************** @ TK2MSFTNGP11.phx.gbl ...
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If Ctrl.ControlType <> acLabel And Ctrl.ControlType <> acCommandButton Then
If Not IsNull(Ctrl.Value) Then
If InStr(Ctrl.Value, vbCrLf) > 0 Then
MsgBox Ctrl.Controls(0).Caption & " Contains A Line Return." & vbCrLf &
vbCrLf _
& "The New Item Can Not Be Saved In The Database" & vbCrLf _
& "Until The Line Return Is Removed." & vbCrLf & vbCrLf _
& "Please Remove The Line Return!"
Cancel = True
Ctrl.SetFocus
Exit Sub
End If
End If
End If
Next Ctrl

'' BeforeUpdate Event Is Used For This So InvNumber = StoreItemID When The Item
Is Saved
Me!InvNumber = Me!StoreItemID
If Me!SetThisItemAsTheDefaultNewItem = True Then
Call SetDefaultValues
Else
Call RemoveDefaultValues
End If
Me!Title.SetFocus
End Sub

Public Sub SetDefaultValues()
On Error GoTo ErrorHandler
Me!Title.DefaultValue = CQuote & Me!Title & CQuote
Me!FeatureFlag.DefaultValue = CQuote & Me!FeatureFlag & CQuote
Me!ShortDesc.DefaultValue = CQuote & Me!ShortDesc & CQuote
Me!Description.DefaultValue = CQuote & Me!Description & CQuote
Me!ThumbImage.DefaultValue = CQuote & Me!ThumbImage & CQuote
Me!FullImage.DefaultValue = CQuote & Me!FullImage & CQuote

If Not IsNull(Me!Category) Then
Me!Category.DefaultValue = CQuote & Me!Category & CQuote
Else
Me!Category.DefaultValue = ""
End If
If Not IsNull(Me!Section) Then
Me!Section.DefaultValue = CQuote & Me!Section & CQuote
Else
Me!Section.DefaultValue = ""
End If
If Not IsNull(Me!Aisle) Then
Me!Aisle.DefaultValue = CQuote & Me!Aisle & CQuote
Else
Me!Aisle.DefaultValue = ""
End If

Me!Alt1.DefaultValue = CQuote & Me!Alt1 & CQuote
Me!Alt2.DefaultValue = CQuote & Me!Alt2 & CQuote
Me!Alt3.DefaultValue = CQuote & Me!Alt3 & CQuote
Me!ListValue.DefaultValue = CQuote & Me!ListValue & CQuote
Me!SalePrice.DefaultValue = CQuote & Me!SalePrice & CQuote
Me!SellingPrice.DefaultValue = CQuote & Me!SellingPrice & CQuote
Me!DatePurchased.DefaultValue = CQuote & Me!DatePurchased & CQuote
Me!ItemCost.DefaultValue = CQuote & Me!ItemCost & CQuote
Me!ShipCost.DefaultValue = CQuote & Me!ShipCost & CQuote

If Not IsNull(Me!InventoryLocation) Then
Me!InventoryLocation.DefaultValue = CQuote & Me!InventoryLocation & CQuote
Else
Me!InventoryLocation.DefaultValue = ""
End If

Me!Inventory.DefaultValue = CQuote & Me!Inventory & CQuote
Me!ReorderPoint.DefaultValue = CQuote & Me!ReorderPoint & CQuote
Me!Quantity.DefaultValue = CQuote & Me!Quantity & CQuote
ExitHere:
Me!Title.SetFocus
Exit Sub
ErrorHandler:
MsgBox Err.Description, , "Error# " & Err.Number
Resume ExitHere
End Sub

Public Sub RemoveDefaultValues()
Me!Title.DefaultValue = ""
Me!FeatureFlag.DefaultValue = ""
Me!ShortDesc.DefaultValue = ""
Me!Description.DefaultValue = ""
Me!ThumbImage.DefaultValue = ""
Me!FullImage.DefaultValue = ""
Me!Category.DefaultValue = ""
Me!Section.DefaultValue = ""
Me!Aisle.DefaultValue = ""
Me!Alt1.DefaultValue = ""
Me!Alt2.DefaultValue = ""
Me!Alt3.DefaultValue = ""
Me!ListValue.DefaultValue = ""
Me!SalePrice.DefaultValue = ""
Me!SellingPrice.DefaultValue = ""
Me!DatePurchased.DefaultValue = ""
Me!ItemCost.DefaultValue = ""
Me!ShipCost.DefaultValue = ""
Me!InventoryLocation.DefaultValue = ""
Me!Inventory.DefaultValue = ""
Me!ReorderPoint.DefaultValue = ""
Me!Quantity.DefaultValue = ""
End Sub

"Dirk Goldgar" <dg@NOdataSPAMgnostics.com> wrote in message
news:Oa**************@TK2MSFTNGP11.phx.gbl...
" Steve" < SP ** @ nospam.spam>在消息中写道
新闻:gi ***************** @ newsread3.news.atl.earthl ink.net
"Steve" <sp**@nospam.spam> wrote in message
news:gi*****************@newsread3.news.atl.earthl ink.net
我有一个表格大约25个领域。在
表单的BeforeUpdate事件中,我有代码将每个字段的默认值设置为其当前值。对于新的记录,我可以把焦点放在任何领域来开始。如果我编辑该字段然后单击导航按钮中的新记录按钮
,则表单将转到新记录,并且每个
字段都具有上一记录的默认值。如果我把
焦点放在任何一个字段中开始,编辑该字段转到任何其他字段
并编辑它,当我点击导航中的新记录按钮
按钮时表单确实如此没有去新的记录。我必须再次点击新的
记录按钮才能转到新记录。我也尝试过把代码设置为
表单的AfterUpdate事件中的默认值,我也遇到了两次点击新记录
按钮的问题。

有没有人想过可能导致这种行为的原因?

谢谢!

史蒂夫
I have a form with about 25 fields. In the BeforeUpdate event of the
form, I have code that sets the default value of each field to its
current value. For a new record, I can put the focus in any field to
start. If I edit that field and then click on the new record button
in the navigation buttons, the form goes to a new record and each
field has the default value of the previous record. If I put the
focus in any field to start, edit that field go to any other field
and edit it, when I click on the new record button in the navigation
buttons the form does not go to a new record. I have to click the new
record button a second time to go to a new record. I also tried
putting the code to set the defaults in the AfterUpdate event of the
form and I get the same problem of having to click on the new record
button twice.

Does anyone have any thoughts as to what may be causing this
behaviour?

Thanks!

Steve



我想你最好发布表格背后的代码。

- Dirk Goldgar,MS Access MVP
www.datagnostics.com

(请回复新闻组)



I think you''d better post the code behind the form.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)



" Steve" < SP ** @ nospam.spam>在消息中写道

news:ks ***************** @ newsread2.news.atl.earthl ink.net
"Steve" <sp**@nospam.spam> wrote in message
news:ks*****************@newsread2.news.atl.earthl ink.net
Private Sub Form_BeforeUpdate(取消为整数)
Dim Ctrl As Control
For Me.Controls中的每个Ctrl
如果Ctrl.ControlType<> acLabel和Ctrl.ControlType<>
acCommandButton然后如果不是IsNull(Ctrl.Value)那么
如果InStr(Ctrl.Value,vbCrLf)> 0然后
MsgBox Ctrl.Controls(0).Caption& "包含一行返回。
& vbCrLf& vbCrLf _
& 新项目无法保存在数据库中 &安培; vbCrLf _
& 直到删除换行符。 &安培; vbCrLf& vbCrLf _
& 请删除行返回!
取消=真
Ctrl.SetFocus
退出子
结束如果
结束如果
结束如果
下一步

''BeforeUpdate事件用于此所以InvNumber = StoreItemID当
项目被保存
我!InvNumber =我!StoreItemID
如果我!SetThisItemAsTheDefaultNewItem = True然后
调用SetDefaultValues
否则
调用RemoveDefaultValues
结束如果
我!Title.SetFocus
End Sub
Public Sub SetDefaultValues()
On Error GoTo ErrorHandler
我!Title.DefaultValue = CQuote&我!标题& CQuote
我!FeatureFlag.DefaultValue = CQuote&我!FeatureFlag& CQuote
我!ShortDesc.DefaultValue = CQuote&我!ShortDesc& CQuote
我!Description.DefaultValue = CQuote&我!描述& CQuote
我!ThumbImage.DefaultValue = CQuote&我!ThumbImage& CQuote
我!FullImage.DefaultValue = CQuote&我!FullImage& CQuote

如果不是IsNull(我!类别)那么
我!Category.DefaultValue = CQuote&我!类别& CQuote
Else
我!Category.DefaultValue =""
结束如果
如果不是IsNull(我!部分)那么
我!Section.DefaultValue = CQuote &安培;我!部分& CQuote
其他
我!Section.DefaultValue =""
结束如果
如果不是IsNull(Me!Aisle)那么
我!Aisle.DefaultValue = CQuote &安培;我!过道& CQuote
其他
我!Aisle.DefaultValue =""
结束如果

我!Alt1.DefaultValue = CQuote&我!Alt1& CQuote
我!Alt2.DefaultValue = CQuote&我!Alt2& CQuote
我!Alt3.DefaultValue = CQuote&我!Alt3& CQuote
我!ListValue.DefaultValue = CQuote&我!ListValue& CQuote
我!SalePrice.DefaultValue = CQuote&我!SalePrice& CQuote
我!SellingPrice.DefaultValue = CQuote&我!销售价格& CQuote
我!DatePurchased.DefaultValue = CQuote&我!DatePurchased& CQuote
我!ItemCost.DefaultValue = CQuote&我!ItemCost& CQuote
我!ShipCost.DefaultValue = CQuote&我!ShipCost& CQuote

如果不是IsNull(我!InventoryLocation)那么
我!InventoryLocation.DefaultValue = CQuote&我!InventoryLocation&
CQuote Else
我!InventoryLocation.DefaultValue =""
结束如果

我!Inventory.DefaultValue = CQuote&我!库存& CQuote
我!ReorderPoint.DefaultValue = CQuote&我!ReorderPoint& CQuote
我!Quantity.DefaultValue = CQuote&我!数量& CQuote

ExitHere:
我!Title.SetFocus
退出Sub
ErrorHandler:
MsgBox Err.Description,Error# &安培; Err.Number
Resume ExitHere
End Sub

Public Sub RemoveDefaultValues()
我!Title.DefaultValue =""
我!FeatureFlag。 DefaultValue =""
Me!ShortDesc.DefaultValue =""
Me!Description.DefaultValue =""
Me!ThumbImage.DefaultValue =""
我!FullImage.DefaultValue =""
Me!Category.DefaultValue =""
Me!Section.DefaultValue =""
Me!Aisle.DefaultValue = "
Me!Alt1.DefaultValue =""
Me!Alt2.DefaultValue =""
Me!Alt3.DefaultValue =""
我!ListValue.DefaultValue =""
Me!SalePrice.DefaultValue =""
Me!SellingPrice.DefaultValue =""
Me!DatePurchased.DefaultValue ="
Me!ItemCost.DefaultValue =""
Me!ShipCost.DefaultValue =""
Me!InventoryLocation.DefaultValue =""
我! Inventory.De faultValue =""
Me!ReorderPoint.DefaultValue =""
Me!Quantity.DefaultValue =""
End Sub

" Dirk Goldgar < dg@NOdataSPAMgnostics.com>在消息中写道
新闻:Oa ************** @ TK2MSFTNGP11.phx.gbl ...
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If Ctrl.ControlType <> acLabel And Ctrl.ControlType <>
acCommandButton Then If Not IsNull(Ctrl.Value) Then
If InStr(Ctrl.Value, vbCrLf) > 0 Then
MsgBox Ctrl.Controls(0).Caption & " Contains A Line Return."
& vbCrLf & vbCrLf _
& "The New Item Can Not Be Saved In The Database" & vbCrLf _
& "Until The Line Return Is Removed." & vbCrLf & vbCrLf _
& "Please Remove The Line Return!"
Cancel = True
Ctrl.SetFocus
Exit Sub
End If
End If
End If
Next Ctrl

'' BeforeUpdate Event Is Used For This So InvNumber = StoreItemID When
The Item Is Saved
Me!InvNumber = Me!StoreItemID
If Me!SetThisItemAsTheDefaultNewItem = True Then
Call SetDefaultValues
Else
Call RemoveDefaultValues
End If
Me!Title.SetFocus
End Sub

Public Sub SetDefaultValues()
On Error GoTo ErrorHandler
Me!Title.DefaultValue = CQuote & Me!Title & CQuote
Me!FeatureFlag.DefaultValue = CQuote & Me!FeatureFlag & CQuote
Me!ShortDesc.DefaultValue = CQuote & Me!ShortDesc & CQuote
Me!Description.DefaultValue = CQuote & Me!Description & CQuote
Me!ThumbImage.DefaultValue = CQuote & Me!ThumbImage & CQuote
Me!FullImage.DefaultValue = CQuote & Me!FullImage & CQuote

If Not IsNull(Me!Category) Then
Me!Category.DefaultValue = CQuote & Me!Category & CQuote
Else
Me!Category.DefaultValue = ""
End If
If Not IsNull(Me!Section) Then
Me!Section.DefaultValue = CQuote & Me!Section & CQuote
Else
Me!Section.DefaultValue = ""
End If
If Not IsNull(Me!Aisle) Then
Me!Aisle.DefaultValue = CQuote & Me!Aisle & CQuote
Else
Me!Aisle.DefaultValue = ""
End If

Me!Alt1.DefaultValue = CQuote & Me!Alt1 & CQuote
Me!Alt2.DefaultValue = CQuote & Me!Alt2 & CQuote
Me!Alt3.DefaultValue = CQuote & Me!Alt3 & CQuote
Me!ListValue.DefaultValue = CQuote & Me!ListValue & CQuote
Me!SalePrice.DefaultValue = CQuote & Me!SalePrice & CQuote
Me!SellingPrice.DefaultValue = CQuote & Me!SellingPrice & CQuote
Me!DatePurchased.DefaultValue = CQuote & Me!DatePurchased & CQuote
Me!ItemCost.DefaultValue = CQuote & Me!ItemCost & CQuote
Me!ShipCost.DefaultValue = CQuote & Me!ShipCost & CQuote

If Not IsNull(Me!InventoryLocation) Then
Me!InventoryLocation.DefaultValue = CQuote & Me!InventoryLocation &
CQuote Else
Me!InventoryLocation.DefaultValue = ""
End If

Me!Inventory.DefaultValue = CQuote & Me!Inventory & CQuote
Me!ReorderPoint.DefaultValue = CQuote & Me!ReorderPoint & CQuote
Me!Quantity.DefaultValue = CQuote & Me!Quantity & CQuote
ExitHere:
Me!Title.SetFocus
Exit Sub
ErrorHandler:
MsgBox Err.Description, , "Error# " & Err.Number
Resume ExitHere
End Sub

Public Sub RemoveDefaultValues()
Me!Title.DefaultValue = ""
Me!FeatureFlag.DefaultValue = ""
Me!ShortDesc.DefaultValue = ""
Me!Description.DefaultValue = ""
Me!ThumbImage.DefaultValue = ""
Me!FullImage.DefaultValue = ""
Me!Category.DefaultValue = ""
Me!Section.DefaultValue = ""
Me!Aisle.DefaultValue = ""
Me!Alt1.DefaultValue = ""
Me!Alt2.DefaultValue = ""
Me!Alt3.DefaultValue = ""
Me!ListValue.DefaultValue = ""
Me!SalePrice.DefaultValue = ""
Me!SellingPrice.DefaultValue = ""
Me!DatePurchased.DefaultValue = ""
Me!ItemCost.DefaultValue = ""
Me!ShipCost.DefaultValue = ""
Me!InventoryLocation.DefaultValue = ""
Me!Inventory.DefaultValue = ""
Me!ReorderPoint.DefaultValue = ""
Me!Quantity.DefaultValue = ""
End Sub

"Dirk Goldgar" <dg@NOdataSPAMgnostics.com> wrote in message
news:Oa**************@TK2MSFTNGP11.phx.gbl...
" Steve" < SP ** @ nospam.spam>在消息中写道
新闻:gi ***************** @ newsread3.news.atl.earthl ink.net
"Steve" <sp**@nospam.spam> wrote in message
news:gi*****************@newsread3.news.atl.earthl ink.net
我有一个表格大约25个领域。在
表单的BeforeUpdate事件中,我有代码将每个字段的默认值设置为其当前值。对于新的记录,我可以把焦点放在任何领域来开始。如果我编辑该字段然后单击导航按钮中的新记录按钮
,则表单将转到新记录,并且每个
字段都具有上一记录的默认值。如果我把
焦点放在任何一个字段中开始,编辑该字段转到任何其他字段
并编辑它,当我点击导航中的新记录按钮
按钮时表单确实如此没有去新的记录。我必须再次单击
新记录按钮才能转到新记录。我也尝试过把代码设置为
表单的AfterUpdate事件中的默认值,我也遇到了两次点击新记录
按钮的问题。

有没有人想过可能导致这种行为的原因?

谢谢!

史蒂夫
I have a form with about 25 fields. In the BeforeUpdate event of the
form, I have code that sets the default value of each field to its
current value. For a new record, I can put the focus in any field to
start. If I edit that field and then click on the new record button
in the navigation buttons, the form goes to a new record and each
field has the default value of the previous record. If I put the
focus in any field to start, edit that field go to any other field
and edit it, when I click on the new record button in the navigation
buttons the form does not go to a new record. I have to click the
new record button a second time to go to a new record. I also tried
putting the code to set the defaults in the AfterUpdate event of the
form and I get the same problem of having to click on the new record
button twice.

Does anyone have any thoughts as to what may be causing this
behaviour?

Thanks!

Steve



我想你最好发布表格背后的代码。



I think you''d better post the code behind the form.




我不得不说它并不明显。让我验证一下。


是新记录吗?按钮是否单击标准

导航按钮之一,将表单''的NavigationButtons

属性设置为是?


当我解释您对问题的描述时,您对比了两个

行为,在下面标识为A和B:


(A)打开形成。转到新记录。编辑控件中的数据。点击

" new record"按钮。表格转到新纪录。


(B)开放表格。转到新记录。编辑控件中的数据。编辑另一个控件中的

数据。点击新记录按钮。表格确实*不*将

换成新记录,但保留在当前记录中。如果再次单击

按钮,*然后*表单将转到新记录。


上述说明是否正确描述了您正在做什么和看到的内容?

请确认确切知道如何获得不同的行为,

每次从表格的新开头开始。你确定吗

无关紧要你编辑什么控件?


我注意到你的代码循环通过控件只排除了

标签和命令按钮。可以想象还有其他类型的

控件没有Value属性 - 线条,方框等。

你确定你不是吗?有问题吗?你没有错误

陷阱被关闭,是吗?

Form_BeforeUpdate程序中没有错误处理。


-

Dirk Goldgar,MS Access MVP www.datagnostics.com


(请回复新闻组)



I have to say it''s not obvious. Let me verify a couple of things.

Is the "new record" button you''re clicking one of the standard
navigation buttons provided by having the form''s NavigationButtons
property set to Yes?

As I interpret your description of the problem, you are contrasting two
behaviors, identified as A and B below:

(A) Open Form. Go to new record. Edit the data in a control. Click
"new record" button. Form goes to a new record.

(B) Open Form. Go to new record. Edit the data in a control. Edit the
data in another control. Click "new record" button. Form does *not* go
to a new record, but stays on the current record. If you click the
button again, *then* the form goes to a new record.

Do the above statements correctly decribe what you are doing and seeing?
Please verify exactly what it takes to get the dfferent behaviors,
starting with a fresh opening of the form each time. Are you sure it
doesn''t matter what controls you edit?

I notice that your code that loops through the controls excludes only
labels and command buttons. There could conceivably be other types of
controls that don''t have a Value property -- lines, boxes, and such.
Are you sure you don''t have a problem there? You don''t have error
trapping turned off, do you? You have no error-handling in the
Form_BeforeUpdate procedure.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


这篇关于表格不会进入新纪录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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