English 中文(简体)
在MS Access中,从表单2添加后,如何选择表单1上的记录?
原标题:In MS Access, how to select record on form1 after adding from form2?

这是我的场景(MS Access 2007):

在Form1上,我有一个记录(订单)列表。Form1有一个启动Form2的按钮。

Form2用于创建新订单。Form2上的“保存”按钮使用VBA保存记录,关闭表单并重新查询Form1:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.RunCommand acCmdCloseWindow
Forms!Orders.Requery

我想做的下一步是在Form1上自动选择新记录。我猜这是用<code>DoCmd.FindRecord</code>完成的吗?我想不通--我们非常感谢您的帮助。

Thanks, Stewart

最佳回答

答案将取决于应用程序是具有单个用户还是具有多个用户。在多用户场景中,简单地获得最近添加的订单不一定会返回您刚刚输入的订单。但如果只有你,获得最近增加的价值就能做到这一点。

如果使用的是自动递增键,则可以找到具有max(orderid)的行;或者如果您的订单带有时间戳,则查找具有最大值(orderDateTime)的行;或者简单地让Orderslist表单的数据源按照其中一个值进行排序,降序排列,然后重新定位到Requery之后的第一条记录。

问题回答

暂无回答




相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

access query to filter and combine count

i have two access tables tableA num count 1 7 2 8 3 9 4 9 5 13 6 6 tableB num count 0 1 1 14 2 12 3 5 4 5 5 11 6 5 how can i create an access query that ...

How to show File Picker dialog in Access 2007?

I want to show a dialog where the user can pick a file, click OK, and then the path to the file will be saved in the database. I have just one problem, I can t figure out how tho show the dialog ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

Returning row number on MS Access

I have 4 tables, from which i select data with help of joins in select query...I want a serial no.(row number) per record as they are fetched. first fetched record should be 1, next 2 and so on... In ...

热门标签