如何索取表格的最后一条记录的ID?

编程入门 行业动态 更新时间:2024-10-27 06:32:18
本文介绍了如何索取表格的最后一条记录的ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我目前在接入的形式。

I currently have a form in access.

我想要做的就是添加的最后一个记录的值。

What I want to do is get the value of the last record added.

例如,如果我有10条记录,我想要得到的值10,因为这是最后添加记录的ID。我想运行的功能最后一个ID插入()查询,但它不能正常工作。

For example, if i have 10 records, I want to get the value "10", because this is the id of the added last record. I am trying to run a query with the function last id inserted() but it is not working.

这在code我使用的:

This the code I am using :

Dim lastID As Integer Query = "select last_insert_id()" lastID = Query MsgBox (lastID)

我在想什么?

What am I missing?

推荐答案

有一个函数 DMAX 将抓取的最高数量。

There is a function DMax that will grab the highest number.

Dim lastID As Integer lastID = DMax("IDField","YourTable") ' or = DMax("IDField","YourTable","WhenField=Value") MsgBox lastID

其他的域功能的是:

  • DAVG
  • DCOUNT
  • DFirst
  • DLast
  • 使用DLookup
  • DMIN
  • DSTDEV
  • DSTDEVP
  • 使用DSum
  • 女工
  • DVARP
  • DAvg
  • DCount
  • DFirst
  • DLast
  • DLookup
  • DMin
  • DStDev
  • DStDevP
  • DSum
  • DVar
  • DVarP

请与你的友好 F1 键以获得更多信息。

Check with your friendly F1 key for more info

更多推荐

如何索取表格的最后一条记录的ID?

本文发布于:2023-10-20 12:58:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1511034.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表格   ID

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!