NotInList每次都将新条目添加为新记录 [英] NotInList adding new entry as a new record each time

查看:73
本文介绍了NotInList每次都将新条目添加为新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨......我在表格上有很多组合框。如果键入一个不在表中的名称

,我希望它添加键入的新项目。我用

使用以下代码执行此操作并且效果很好,除了一个

之外 - 每个新项目都添加为新记录。我希望在相关字段中的最后一个条目之后添加新名称

...这是否可能

- 最好是通过调整我正在使用的代码? br $>
Private Sub Supermarket_NotInList(NewData As String,响应为

整数)

Dim Db作为DAO.Database

Dim Rs作为DAO.Recordset

Dim Msg As String

Msg ="''" &安培; NewData& '不在列表中。 &安培; vbCr& vbCr

Msg = Msg& 你要添加它吗?

如果MsgBox(Msg,vbQuestion + vbYesNo)= vbNo那么

响应= acDataErrContinue

MsgBox再试一次。

否则

设置Db = CurrentDb

设置Rs = Db.OpenRecordset(" Businesses",dbOpenDynaset )

Rs.AddNew

Rs![超市] = NewData

Rs.Update

响应= acDataErrAdded

结束如果

结束子


谢谢...... Rob

Hi...I have a number of Combo Boxes on a form. If one types a name
which is not in the table, I want it to add the typed, new item. I am
using the following code to do this and it works well, except for one
thing - each new item is added as a new record. I want the new name to
be added after the last entry in the relevant field...is this possible
- preferably by tweaking the code I am using already?

Private Sub Supermarket_NotInList(NewData As String, Response As
Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String
Msg = "''" & NewData & "'' is not in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Try again."
Else
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("Businesses", dbOpenDynaset)
Rs.AddNew
Rs![Supermarket] = NewData
Rs.Update
Response = acDataErrAdded
End If
End Sub

Thanks...Rob

推荐答案

如果您的表中有自动编号,请对业务进行排序。在自动编号

字段上升或下降取决于您希望如何查看列表。在响应= acDataErrAdded之后,在代码中添加

以下行:

Me!NameOfCombobox.Requery


-

PC数据表

您的资源以获取访问,Excel和Word应用程序的帮助

超过1175位用户来自新闻组请求帮助
re******@pcdatasheet.com


< ro ******@gmail.com>在消息中写道

新闻:11 ********************** @ j73g2000cwa.googlegr oups.com ...
If you have an autonumber in your table, sort "Businesses" on the autonumber
field ascending or descending depending on how you want to see the list. Add
the following line to your code after Response = acDataErrAdded:
Me!NameOfCombobox.Requery

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
Over 1175 users have come to me from the newsgroups requesting help
re******@pcdatasheet.com

<ro******@gmail.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
嗨......我在表格上有很多组合框。如果键入一个不在表中的名称
,我希望它添加键入的新项目。我使用以下代码来执行此操作并且它运行良好,除了一个
之外 - 每个新项目都添加为新记录。我希望在相关领域的最后一个条目之后添加新名称......这是否可能
- 最好通过调整我正在使用的代码?

私人Sub Supermarket_NotInList(NewData As String,Response As
Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String
Msg =" ; '' " &安培; NewData& '不在列表中。 &安培; vbCr& vbCr
Msg = Msg& 你要添加它吗?
如果MsgBox(Msg,vbQuestion + vbYesNo)= vbNo那么
响应= acDataErrContinue
MsgBox再试一次。
否则
设置Db = CurrentDb
设置Rs = Db.OpenRecordset(业务,dbOpenDynaset)
Rs.AddNew
Rs![超市] = NewData
Rs 。更新
响应= acDataErrAdded
结束如果
结束子

谢谢...... Rob
Hi...I have a number of Combo Boxes on a form. If one types a name
which is not in the table, I want it to add the typed, new item. I am
using the following code to do this and it works well, except for one
thing - each new item is added as a new record. I want the new name to
be added after the last entry in the relevant field...is this possible
- preferably by tweaking the code I am using already?

Private Sub Supermarket_NotInList(NewData As String, Response As
Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String
Msg = "''" & NewData & "'' is not in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Try again."
Else
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("Businesses", dbOpenDynaset)
Rs.AddNew
Rs![Supermarket] = NewData
Rs.Update
Response = acDataErrAdded
End If
End Sub

Thanks...Rob





" PC数据表" <否**** @ Spam.Com> schreef在bericht新闻:我**************** @ newsread3.news.pas.earthli nk.net ...


-

-

"PC Datasheet" <No****@Spam.Com> schreef in bericht news:me****************@newsread3.news.pas.earthli nk.net...

--
--
PC数据表
您的资源获取Access,Excel和Word应用程序的资源帮助?
超过1175位用户来自新闻组请求帮助''1175位用户????
重新* *****@pcdatasheet.com




-

给Steve:

没有人想要你的广告/求职!

超过875!来自新闻组的用户已经访问过该网站以阅读您所使用的资源...(迅速增加......)


到原始海报:

这里的大多数人都有一个共同的信念,即新闻组是*免费的信息交换*。

但史蒂夫是这些团体中臭名昭着的求职者,总是试图出售他的服务。

他在这里被认为是一个没有道德的无耻的骗子。


在你打算与他做生意之前看看:
http://home.tiscali.nl/arracom/whoissteve.html


Arno R



--
To Steve:
No-one wants your advertising/job hunting here!
Over 875 !! users from the newsgroups have visited the website to read what kind of a ''resource'' you are... (rapidly increasing..)

To the original poster:
Most people here have a common belief that the newsgroups are for *free exchange of information*.
But Steve is a notorious job hunter in these groups, always trying to sell his services.
And he is known here as a shameless liar with no ethics at all.

Before you intend to do business with him look at:
http://home.tiscali.nl/arracom/whoissteve.html

Arno R


比他的广告更糟糕的是他发送电子邮件给
$ b $的人b问这个问题试图让他们付钱帮助他们。


真的让你不想再写信了。


我已经得到了我的份额来自他的电子邮件提供他的帮助,收费。



StopThisAdvertising < StopThisAdvertising @ DataShit>在消息中写道

news:44 ********************** @ text.nova.planet.nl。 ..


" PC数据表" <否**** @ Spam.Com> schreef in bericht

新闻:我**************** @ newsread3.news.pas.earthli nk.net ...


-

-
Whats worse than his advertising is his sending emails to the person who
asks the question trying to get them to pay him to help them.

Really makes you not want to even write to the group anymore.

I''ve gotten my share of emails from him offering his help for a fee.



"StopThisAdvertising" <StopThisAdvertising@DataShit> wrote in message
news:44**********************@text.nova.planet.nl. ..

"PC Datasheet" <No****@Spam.Com> schreef in bericht
news:me****************@newsread3.news.pas.earthli nk.net...

--
--
PC数据表
您的资源以获取Access,Excel和Word应用程序的帮助
''资源????超过1175位用户来自新闻组请求帮助
''1175用户???? re******@pcdatasheet.com




-

史蒂夫:

没有人想要你的广告/求职!

超过875!来自新闻组的用户已经访问过该网站阅读了什么

你的资源类型......(迅速增加......)


致原始海报:

这里的大多数人都有一个共同的信念,即新闻组是*免费的

交换信息*。

但史蒂夫在这些团体中是一个臭名昭着的求职者,总是试图出售他的服务。

他在这里被称为一个没有道德的无耻的骗子。


在你打算与他做生意之前,请看看:
http://home.tiscali.nl/arracom/whoissteve.html

Arno R



--
To Steve:
No-one wants your advertising/job hunting here!
Over 875 !! users from the newsgroups have visited the website to read what
kind of a ''resource'' you are... (rapidly increasing..)

To the original poster:
Most people here have a common belief that the newsgroups are for *free
exchange of information*.
But Steve is a notorious job hunter in these groups, always trying to sell
his services.
And he is known here as a shameless liar with no ethics at all.

Before you intend to do business with him look at:
http://home.tiscali.nl/arracom/whoissteve.html

Arno R

这篇关于NotInList每次都将新条目添加为新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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