帮助重复记录,更改字段 [英] Help with duplicate record, with changed field

查看:66
本文介绍了帮助重复记录,更改字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Access 2003中工作。

我已经设法使用代码上的按钮复制记录:

Private Sub Command16_Click()

On Error GoTo Err_Command16_Click


DoCmd.DoMenuItem acFormBar,acEditMenu,8 ,, acMenuVer70

DoCmd.DoMenuItem acFormBar,acEditMenu,2, ,acMenuVer70

DoCmd.DoMenuItem acFormBar,acEditMenu,5,acMenuVer70''粘贴附加


Exit_Command16_Click:

退出Sub


Err_Command16_Click:

MsgBox Err.Description

恢复退出_Command16_Click


结束Sub



但是这只是在表单上创建了一个字段的副本,这很好,但是我也希望+1到新记录中的一个字段。


这可能吗?如果是这样我怎么办呢。



另外.....

如果可以的话,

也可以有一个下拉菜单选择say(n)1-9,这是用字段+(n)做多少重复。

所以第一个副本将是相同的但是一个字段将具有+1,并且下一个+2等等

所选字段数

解决方案

设'假设有一个包含字段txtName,txtAddress和numID的表tblStuff。我们还假设您想增加numID,并且您正在复制最后一条记录。

展开 | 选择 | 换行 | 行号


< blockquote>创建新的重复记录后,只需参考相关控件并添加1


我!YOURTEXTBOX =我!YOURTEXTBOX + 1




为了打破它,它看起来就像这样:


Private Sub Command16_Click()

出错时GoTo Err_Command16_Click

Dim i为整数,cnt为整数


cnt =我!COUNTTEXTBOXNAME


对于i = 0到cnt

DoCmd.DoMenuItem acFormBar,acEditMenu,8 ,, acMenuVer70

DoCmd.DoMenuItem acFormBar,acEditMenu,2,acMenuVer70

DoCmd.DoMenuItem acFormBar,acEditMenu,5,acMenuVer70''粘贴附加


我!YOURTEXTBOX =我!YOURTEXTBOX + 1


next


Exit_Command16_Click:

退出Sub


Err_Command16_Click:

MsgBox Err.Description

恢复Exit_Command16_Click


End Sub


作为旁注,我没有检查你正在使用菜单栏命令做什么,这些命令有时很麻烦(功能不正确)我建议在代码中这样做会更加可靠。 。


查看以下文章:
http://support.microsoft.com/kb/210236

Working in Access 2003.
I have managed to duplicate a record using a button on a form with code:

Private Sub Command16_Click()
On Error GoTo Err_Command16_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 ''Paste Append

Exit_Command16_Click:
Exit Sub

Err_Command16_Click:
MsgBox Err.Description
Resume Exit_Command16_Click

End Sub


But this just creates a duplicate of the fields on the form, which is fine, but i would also like to +1 to one of the fields on the new record.

Is this possible? If so how would i do it.



Also.....
If this is possible,
would it also be possible to have a drop down menu in which to select say (n)1-9 and that is how many duplicates it will make with field +(n).
so the first duplicate will be the same but a field will have +1, and the next +2, etc.
for the selected number of fields

解决方案

Let''s Assume that there is a table tblStuff with fields txtName, txtAddress, and numID. Let''s also assume that you wanted to increment numID and you are copying the last record made.

Expand|Select|Wrap|Line Numbers


After the new duplicate record is created then simply refer to the control in question and add 1

Me!YOURTEXTBOX = Me!YOURTEXTBOX+1



To break it down it would simply look like so:


Private Sub Command16_Click()
On Error GoTo Err_Command16_Click
Dim i as integer, cnt as integer

cnt = Me!COUNTTEXTBOXNAME

For i = 0 to cnt
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 ''Paste Append

Me!YOURTEXTBOX = Me!YOURTEXTBOX+1

next

Exit_Command16_Click:
Exit Sub

Err_Command16_Click:
MsgBox Err.Description
Resume Exit_Command16_Click

End Sub


As a side note I didnt check to see what you were doing with the menubar commands those commands can be troublesome at times (not function correctly) I would suggest doing this in code it would be much more reliable..


Check out the following article:
http://support.microsoft.com/kb/210236


这篇关于帮助重复记录,更改字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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