DLast不会返回高于255的值? [英] DLast won't return value higher than 255?

查看:92
本文介绍了DLast不会返回高于255的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天!首先,我要感谢社区作为一个整体提供您提供的宝贵信息。在过去的几周里,我一直在教自己Access / VBA,同时建立一个数据库/结账系统,如果没有我在这个网站上找到的问题和有见地的答案,我就没有什么可以展示的。所以你很棒。


话虽如此,我终于遇到了一个问题,我无法找到问题或答案。


悬崖问题的注意事项是这样的(使用Access 2013):


当我在其中一张桌子上运行DLast时,它继续给出结果自从我达到记录#255以来就是255。我不知道它是巧合的,它确实是255或者这意味着什么。


这是一个问题,因为我使用DLast在一个单独的表单上填充一个字段(它读取最后一个ID#并用它来填充主表单上的组合框,节省了我从键入一个名称多次来分配它)。


这项技术一直在努力,直到我达到记录#255。从那以后,它一直保持在255.我已经尝试将DLast语句作为变量首先存储而没有运气。我理解255是短文本的最大字符,但是这不处理字符串或文本,只是一个整数。


我用msgbox测试它无论如何都返回255什么。当我将参数更改为不同的表,但是相同类型的自动编号ID字段时,它返回实际的最后一个数字(远高于255)。


有关详细信息,请点击此处该项目的背景:


我正在为一所小学的书房整理数据库/结账系统。与图书馆不同,图书室的书名较少,但比图书馆的书副本多,因为教师会定期检查每本书的4-16份(因为它们必须分发给多个学生)。相关书籍信息是:


标题

作者

阅读水平

类型(小说,非生物,民间故事等)

用法(指导阅读,大书,书/磁带)

位置(我们有两个建筑物,有两个书房)

阅读水平,流派,用法和位置都是1-many关系,而作者与连接它们的tblJunctionBookAuthor表有很多关系。


经过大量工具,youtube查看和论坛抓取,我有一个可靠的表格,可以将新书输入数据库。


表单有一个子表单,允许我分配多个作者来自现有列表(来自tblAuthors)或者,如果作者不存在,则添加一个新列表(List-Limited,其中弹出窗体链接到tblAuthors)。直到我点击AuthorID = 255,系统才能完美运行。我会在弹出窗口中输入我的新作者信息,然后当我点击完成时,它会将记录,setfocus保存到AssignAuthors子窗体,并使用与我的新DLast值相对应的数据填充我的组合框。然而,自#255起,当我添加一个新作者时,dlast函数返回255并且每次使用相同的错误名称填充组合框。


目前,我有600多个在此数据库中输入的标题,包括263位作者和800位书籍作者协会。然而,我不会过去#255,我不能删除那些记录,但那将是相对耗时的(它只有13位作者回来,但它已经超过50列表中的标题)。


如果有人遇到过这种情况或点击了某些内容,那么任何信息都会很棒。事实上,我每次都可以键入错误的名称,但它会为数据输入添加一个步骤,而且众所周知,每增加一步就会乘以记录数量,而我仍然需要5000次...


任何帮助都会很棒。当然,如果需要具体信息,请询问。


谢谢!

Good day! First off, I want to thank the community as a whole for the invaluable information you have provided. I have been teaching myself Access/VBA while building a database/checkout system in the last few weeks and would have nothing to show for it had it not been for the questions and insightful answers I''ve found on this site. So you''re awesome.

That being said, I''ve finally come across an issue for which I can find neither question or answer.

The cliff''s notes of the problem is this (Using Access 2013):

When I run DLast on one of my tables, it has continued to give the result as 255 ever since I reached record #255. I don''t know if it''s a coincidence that it''s exactly 255 or if that means something.

It is a problem, because I use DLast to populate a field on a separate form (It reads the last ID# and uses it to populate a combobox on the main form, saving me from typing a name multiple times to assign it).

This technique was working up until I hit record #255. Since then, it''s remained at 255. I''ve tried storing the DLast statement as a variable first with no luck. I understand 255 is the maximum characters for Short Text, but this doesn''t deal with strings or text, just an integer.

I tested with a msgbox and it returns 255 no matter what. When I changed the parameters to a different table, but the same kind of Autonumber ID field, it returned the actual last number (well above 255).

For more info, here''s the background of the project:

I am putting together a database/checkout system for a book room at an Elementary School. Unlike a library, the the book room has fewer titles, but many more copies than a library would, since teachers regularly check out between 4-16 copies of each book (since they have to be distributed to multiple students). The pertinent book information is:

Title
Author
Reading Level
Genre (fiction,non,bio,folktale,etc)
Usage (guided reading,big book,book/tape)
Location (we have two buildings with two book rooms)

Reading Level, Genre, Usage and Location are all 1-many relationships, and Authors is a many-many relationship with tblJunctionBookAuthor table connecting them.

After much tooling around, youtube viewing and forum crawling, I have a solid form for entering new books into the database.

The form has a subform which allows me to assign multiple authors from an existing list (pulls from tblAuthors) or, if the author doesn''t exist, add a new one (List-Limited with a popup form linked to tblAuthors). Up until I hit AuthorID=255, the system was working flawlessly. I would enter my new author information in the popup form, then when I hit "done", it would save the record, setfocus to the AssignAuthors subform, and populate my combobox with the data that corresponded with whatever my new DLast value was. Since #255, however, when I add a new author, the dlast function returns 255 and the combobox populates with the same wrong name each time.

As it stands, I have over 600 titles entered in this database, with 263 authors and 800-some book-author associations. However, I''m not too far past #255 that I couldn''t delete the records back to that point, but that would be relatively time consuming (it''s only 13 authors back, but it''s over 50 titles up the list).

If anyone has encountered this or if something clicks, any information would be great. As it is, I can type over the incorrect name each time, but it adds a step to data entry, and as we all know, every extra step gets multiplied by the number of records, and I still have 5000 to go...

Any help would be awesome. And of course, if specific information is needed, please ask.

Thanks!

推荐答案

不知道为什么我没有早点想到这个:


作为解决方法,我已经切换到DMax,这有效。由于我正在使用ID字段,因此应始终返回最新条目。仍然没有解释为什么DLast不会做同样的事情......
Don''t know why I didn''t think of this sooner:

As a workaround, I''ve switched to DMax and that works. Since I''m using the ID field, it should always return the latest entry. Still doesn''t explain why DLast wouldn''t do the same thing...


我只是建议使用DMax函数,但我想你已经想到了一个out ....


好​​消息!
I was just going to suggest using the DMax Function instead, but I guess you already figured that one out....

Great news!


我刚尝试在我的一个数据库上使用DLast()并返回了更大的值我们需要查看您的代码(请使用 [CODE /] 按钮发布您的代码)以查看错误。 255是可以存储在单个字节中的最高值,所以我猜它与它的使用方式有关。
I just tried using DLast() on one of my databases and it returned a far larger value than 255. We would need to see your code (please use the [CODE/] button to post your code) in order to see what is wrong. 255 is the highest value that can be stored in a single byte, so I would guess that it has something to do with how it is being used.


这篇关于DLast不会返回高于255的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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