有问题的人 [英] beginer with problem

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

问题描述



在工作中,我为访问中的仪表读数创建了一个数据库。我

不是程序员,但想尝试一下。请回复

详细信息,否则我将丢失。

我想做的是消除某人的可能性

进入不良状态数据。要做到这一点,我想比较

两个不同记录上的相同字段,看看结果是正确的还是负面的。

如果是否定的,则是一个消息框。 />
每条记录都有一个日期''fldDate'',然后是

读数的字段。所以我想的是将

记录集中的最后一条记录与当前字段输入进行比较。这是正确的吗?如果是这样,那么步骤是什么,我迷失了。

Hi,
In work I have created a database for meter readings in access. I
am not a programmer, but would like to try something. Please respond
with detail as I will be lost otherwise.
What I would like to do is eliminate the possibility of someone
entering in bad data. To do this, I want to compare the same field on
two different records to see if the result is possitive or negative.
If negative, a message box.
Each record has a date ''fldDate'' and then the fields for the
readings. So what I was thinking was to compare the last record in a
recordset to the current field input. Is this right? If so, what are
the steps, I am lost.

推荐答案

" GoalieGW" < GO ****** @ ptd.net>在消息中写道

news:11 ********************* @ z14g2000cwz.googlegro ups.com ...
"GoalieGW" <Go******@ptd.net> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...

在工作中,我创建了一个数据库,用于访问中的仪表读数。我不是程序员,但想尝试一下。请回复
详细说明,否则我将丢失。
我想做的是消除某人输入错误数据的可能性。要做到这一点,我想比较两个不同记录上的相同字段,看看结果是正确的还是负面的。
如果是否定的,则是一个消息框。
每个记录都有一个日期' 'fldDate''然后是
读数的字段。所以我想的是将
记录集中的最后一条记录与当前字段输入进行比较。这是正确的吗?如果是这样,那些步骤是什么,我迷失了。
Hi,
In work I have created a database for meter readings in access. I
am not a programmer, but would like to try something. Please respond
with detail as I will be lost otherwise.
What I would like to do is eliminate the possibility of someone
entering in bad data. To do this, I want to compare the same field on
two different records to see if the result is possitive or negative.
If negative, a message box.
Each record has a date ''fldDate'' and then the fields for the
readings. So what I was thinking was to compare the last record in a
recordset to the current field input. Is this right? If so, what are
the steps, I am lost.




你需要在代码中打开一个记录集并转到下一个 - -last记录。

在'更新之前的事件中尝试这样的事情:


Dim rs作为DAO.Recordset,lngCompare As Long

设置rs = Me.RecordsetClone

带rs

。移动最后

。移动前一个

lngCompare =![MyField]

结束


如果Me.txtMyTextBox - lngCompare< 0然后

''你的留言箱代码

取消=真

结束如果


rs 。关闭

设置rs =没什么


这是我头脑中未经测试的空气代码,但它应该让你去了

朝正确的方向。它假定您正在编辑的记录已经保存了。记得用你的应用程序从

替换MyField和txtMyTextBox。


HTH - Keith。
www.keithwilby.com


使用表单的BeforeUpdate事件来检查到目前为止最高的读数

这个仪表在之前的日期。这种事情:


Private Sub Form_BeforeUpdate(取消为整数)

Dim strWhere As String

Dim varResult As Variant

Dim strMsg As String


如果不是(IsNull(Me。[MeterID])或IsNull(Me。[fldDate])或

IsNull(我。[阅读])然后

strWhere ="([MeterID] ="& Me.MeterID&")AND([fldDate]<&& ; _

格式(我。[fldDate]," \ #mm\ / dd \ / yyyy \#")&")"

varResult = DMax(" Reading"," Table1",strWhere)

如果Me.Reading< varResult那么

strMsg ="之前阅读& varResult&。"& vbCrLf& _

仍然继续?

如果MsgBox(strMsg,vbYesNo + vbDefaultButton2) = vbNo然后

取消=真实

''Me.Undo

结束如果

结束如果

结束如果

结束子


假设:

- MeterID是一个用于标识仪表的数字字段。

- fldDate是日期/时间字段。

- 这些字段是见表1.


-

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

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

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

" GoalieGW" < GO ****** @ ptd.net>在消息中写道

news:11 ********************* @ z14g2000cwz.googlegro ups.com ...
Use the BeforeUpdate event of the form to check the highest reading so far
for this meter on a previous date. This kind of thing:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strWhere As String
Dim varResult As Variant
Dim strMsg As String

If Not (IsNull(Me.[MeterID]) Or IsNull(Me.[fldDate]) Or
IsNull(Me.[Reading]) Then
strWhere = "([MeterID] = " & Me.MeterID & ") AND ([fldDate] < " & _
Format(Me.[fldDate], "\#mm\/dd\/yyyy\#") & ")"
varResult = DMax("Reading", "Table1", strWhere)
If Me.Reading < varResult Then
strMsg = "Previous reading of " & varResult & "." & vbCrLf & _
"Continue anyway?"
If MsgBox(strMsg, vbYesNo + vbDefaultButton2) = vbNo Then
Cancel = True
''Me.Undo
End If
End If
End If
End Sub

Assumptions:
- MeterID is a Number field that identifies the meter.
- fldDate is a Date/Time field.
- These fields are found in Table1.

--
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.
"GoalieGW" <Go******@ptd.net> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...

在工作中,我创建了一个数据库,用于访问中的仪表读数。我不是程序员,但想尝试一下。请回复
详细说明,否则我将丢失。
我想做的是消除某人输入错误数据的可能性。要做到这一点,我想比较两个不同记录上的相同字段,看看结果是正确的还是负面的。
如果是否定的,则是一个消息框。
每个记录都有一个日期' 'fldDate''然后是
读数的字段。所以我想的是将
记录集中的最后一条记录与当前字段输入进行比较。这是正确的吗?如果有,那么步骤是什么,我迷失了。
Hi,
In work I have created a database for meter readings in access. I
am not a programmer, but would like to try something. Please respond
with detail as I will be lost otherwise.
What I would like to do is eliminate the possibility of someone
entering in bad data. To do this, I want to compare the same field on
two different records to see if the result is possitive or negative.
If negative, a message box.
Each record has a date ''fldDate'' and then the fields for the
readings. So what I was thinking was to compare the last record in a
recordset to the current field input. Is this right? If so, what are
the steps, I am lost.



GoalieGW写道:
GoalieGW wrote:

在工作中,我为访问中的仪表读数创建了一个数据库。我不是程序员,但想尝试一下。请回复
详细说明,否则我将丢失。
我想做的是消除某人输入错误数据的可能性。要做到这一点,我想比较两个不同记录上的相同字段,看看结果是正确的还是负面的。
如果是否定的,则是一个消息框。
每个记录都有一个日期' 'fldDate''然后是
读数的字段。所以我想的是将
记录集中的最后一条记录与当前字段输入进行比较。这是正确的吗?如果是这样,那么步骤是什么,我迷路了。
Hi,
In work I have created a database for meter readings in access. I
am not a programmer, but would like to try something. Please respond
with detail as I will be lost otherwise.
What I would like to do is eliminate the possibility of someone
entering in bad data. To do this, I want to compare the same field on
two different records to see if the result is possitive or negative.
If negative, a message box.
Each record has a date ''fldDate'' and then the fields for the
readings. So what I was thinking was to compare the last record in a
recordset to the current field input. Is this right? If so, what are
the steps, I am lost.




创建一个类似的查询...


SELECT TOP 1 *

来自TableName

ORDER BY fldDate DESC


该查询将从表中返回一行最近的日期。

然后,您可以使用

Recordset或DLookup()从此查询中检索所需的值。如果你需要

检索不仅仅是几个字段,Recordset会更好,但是需要更多的代码来设置

up。 DLookup()会更简单但效率更低如果你正在修复
多个字段。


实际上如果你创建一个Recordset那么它可以构建针对SQL

语句,如上所述,无需创建单独的查询

。单独创建查询确实有助于使用DLookup()

虽然不需要它来指定行(这将是完全在内部完成的b / b
复杂和无效DLookup()WHERE

参数)。


-

我没有查看电子邮件帐户附件

来自此消息。发送给...

在Hunter dot com的RBrandt



Create a query like...

SELECT TOP 1 *
FROM TableName
ORDER BY fldDate DESC

That query will return the one row from the table with the most recent date.
You can then retrieve the required value(s) from this query with either a
Recordset or with DLookup(). The Recordset would be better if you need to
retrieve more than just a couple fields, but will require more code to set
up. The DLookup() will be simpler but less efficient if you are retreving
more than one field.

Actually if you create a Recordset then it could be built against a SQL
Statement like the one above eliminating the need to create a separate query
at all. Creating the query separately does facilitate the use of DLookup()
though by eliminating the need for it to specify the row (which would be
complicated and ineffiecient to do entirely within the DLookup() WHERE
argument).

--
I don''t check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


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

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