代码中的GOTO索引记录 [英] GOTO Indexed Record in Code

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

问题描述

您好


当表单有一个

主要

索引时,如何转到绑定表单中的特定记录自动编号的ID。我需要访问4个单独的记录,

一次一个。


这适用于RecNO但不适合现场搜索:DoCmd.GoToRecord,

,acGoTo,19

我知道不推荐。


我也在代码中尝试过SQL,但不断收到语法错误:

strSQL =" Select * From" T-Table"其中ID = 20"

设置Rst = CurrentDb.OpenRecordset(strSQL,dbSnapshotOnly)


请帮助

Hello

How do I goto a specific record in a BOUND form when the form has a
primary
index of ID which is autonumbered. I need to visit 4 seperate records,
one at a time.

This works for RecNO but no good for Field search: DoCmd.GoToRecord ,
, acGoTo, 19
And I know is NOT recommended.

I Also tried SQL in code, but keep getting syntax errors:
strSQL = "Select * From "T-Table" Where ID = 20"
Set Rst = CurrentDb.OpenRecordset(strSQL, dbSnapshotOnly)

Please Help

推荐答案

在表单的RecordsetClone上使用FindFirst。


示例:


如果我.Dirty然后''先保存。

Me.Dirty = False

结束如果

With Me.RecordsetClone

.FindFirstID = 20

如果.NoMatch则

MsgBox未找到

否则

Me.Bookmark =。书签

结束如果

结束


-

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

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

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


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

新闻:11 ********************** @ d71g2000cwd.googlegr oups.com ...
Use FindFirst on the RecordsetClone of the form.

Example:

If Me.Dirty Then ''Save first.
Me.Dirty = False
End If
With Me.RecordsetClone
.FindFirst "ID = 20"
If .NoMatch Then
MsgBox "not found"
Else
Me.Bookmark = .Bookmark
End If
End With

--
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.

<Ap******@gmail.com> wrote in message
news:11**********************@d71g2000cwd.googlegr oups.com...
您好

当表单具有自动编号的主要
ID索引时,如何转到绑定表单中的特定记录。我需要一次访问4个单独的记录。

这适用于RecNO但不适合现场搜索:DoCmd.GoToRecord,
,acGoTo,19
我也在代码中尝试过SQL,但不断出现语法错误:
strSQL =" Select * From" T-Table"其中ID = 20"
设置Rst = CurrentDb.OpenRecordset(strSQL,dbSnapshotOnly)
Hello

How do I goto a specific record in a BOUND form when the form has a
primary
index of ID which is autonumbered. I need to visit 4 seperate records,
one at a time.

This works for RecNO but no good for Field search: DoCmd.GoToRecord ,
, acGoTo, 19
And I know is NOT recommended.

I Also tried SQL in code, but keep getting syntax errors:
strSQL = "Select * From "T-Table" Where ID = 20"
Set Rst = CurrentDb.OpenRecordset(strSQL, dbSnapshotOnly)



" Ap ****** @ gmail .COM" <鸭****** @ gmail.com>写在

新闻:11 ********************** @ d71g2000cwd.googlegr psps.com:
"Ap******@gmail.com" <Ap******@gmail.com> wrote in
news:11**********************@d71g2000cwd.googlegr oups.com:
您好

当表格
具有自动编号的主要ID索引时,如何转到BOUND表格中的特定记录。我需要一次访问4个单独的
记录。

这适用于RecNO但不适合现场搜索:
DoCmd.GoToRecord,acGoTo,19
我也在代码中尝试过SQL,但不断出现语法错误:
strSQL =" Select * From" T-Table"其中ID = 20"
设置Rst = CurrentDb.OpenRecordset(strSQL,dbSnapshotOnly)

请帮助
Hello

How do I goto a specific record in a BOUND form when the form
has a primary
index of ID which is autonumbered. I need to visit 4 seperate
records, one at a time.

This works for RecNO but no good for Field search:
DoCmd.GoToRecord , , acGoTo, 19
And I know is NOT recommended.

I Also tried SQL in code, but keep getting syntax errors:
strSQL = "Select * From "T-Table" Where ID = 20"
Set Rst = CurrentDb.OpenRecordset(strSQL, dbSnapshotOnly)

Please Help



你可以使用


rst.findfirst" fieldname =" &安培;标准

如果不是rst。 nomatch然后。

......无论如何。

这对一切都有效,并且可能会使用索引,即使

帮助说它没有。


您可以尝试.seek方法,检查帮助,但它

仅适用于.openrecordset(sql, dbOpenTable)

iirc dbSnapshotOnly应该是dbOpenSnapshot,这可能是

解释你的错误信息。


- < br $> b $ b Bob Quintal


PA是我改变了我的电子邮件地址。


you can use

rst.findfirst "fieldname = " & criteria
if not rst. nomatch then .
...... whatever.
That works on everything, and may use indexes, even though the
help says it doesn''t.

You can try the .seek method, check the help for that, but it
only works with .openrecordset(sql,dbOpenTable)

iirc dbSnapshotOnly should be dbOpenSnapshot, which might
explain your error messages.

--
Bob Quintal

PA is y I''ve altered my email address.


谢谢你回复。


我尝试了艾伦建议的FindFirst方法,并且工作正常。

但是,在过去2小时内阅读了一些帖子,我担心它是否已经过时了。当我拆分数据库

并通过网络运行时,我可能会遇到问题。这些帖子提到了Seek和SQL作为

首选方法,但是,我似乎无法在代码中获得

工作。


AnyThoughts?

ThankYou for the responses.

I tried the FindFirst method that Allen suggested, and it works fine.
But, having read some posts over the last 2-hours, am concerned that it
is "Obsolete" and slow and may cause me problems when I split the DB
and run it over the network. Those posts mention Seek and SQL as the
prefered methods, however, I cannot seem to get the SQL in code to
work.

AnyThoughts?


这篇关于代码中的GOTO索引记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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