刷新控件 [英] Refreshing Controls

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

问题描述

我很遗憾地遇到了同样的问题......我一直在研究它,并且发现了许多类似的案例......但到目前为止,这似乎是最接近的。


对我而言,我不是Access开发或VBA的新手,但我已经被困在这个上几个小时并且正在伸出手。然而,我可以提供更多背景知道为什么我的情况会遇到这个问题。


我刚刚做了一个SQL Server迁移,现在我正在解决新出现的问题SQL后端。这是我无法弄清楚的最后一个:


我有一个带有复选框控件的拆分表单...目前表单不可更新,因为表单绑定到通过DSN-Less连接查看。


这是ringer:我在表单顶部有一个勾选复选框...即使绑定表单不可更新我像这样更新记录:

I unfortunately am having the same issue... I''ve been researching it and have found many similar cases... but so far this seems to be the closest.

For me I am not new to Access development or VBA but I''ve been stuck on this one for hours and am reaching out. I can however provide more background as to why my situation is running into this problem.

I just recently did a SQL Server Migration and am now troubleshooting the issues that have sprung up with the new SQL back end. This is the last one that I can not figure out:

I have a split form with a check box control... currently the form is not updatable because the form is bound to a view through a DSN-Less connection.

Here is the ringer: I have a check all check box at the top of the form... and even though the bound form is not updatable I update the records like so:

展开 | 选择 | Wrap | 行号

推荐答案

将其拆分为:
程序化更新后刷新复选框控件


SixHat - 请不要劫持线程,如果需要上下文,请启动一个带有旧链接的新线程。

Split this from:
Refreshing Checkbox control after programmatic update

SixHat - Please do not hijack threads, start a new thread with a link to the old if needed for context.


我有一个拆分形式
I have a split form



来自虐待狂程序工程师的邪恶思想的创造。


这些表格在做基本显示和编辑约束记录之外的任何事情时都没有麻烦 - 集。 Bytes.com充满了关于这个酷刑设备的线程。

A creation from the evil mind of a sadistic program engineer.

These forms have no end of troubles when doing anything beyond the basic display and edit of bound record-sets. Bytes.com is full of threads regarding this torture device.


... SQL Server迁移,我现在正在排除问题...但现在我不能获取单个复选框以更新但检查all / none代码仍然有效!
...SQL Server Migration and am now troubleshooting the issues...but now I can''t get the individual checkbox to update but the check all/ none code still works!



+ Me.Form.Requery

对这个结构感到好奇,它可以引起一些问题。


+你还没有明确说明这一点;但是,从帖子的第一部分推断尝试将所有 Me.Requery 条目更改为:

+Me.Form.Requery
Curious about this construct, it can cause some issues.

+ You haven''t explicitly stated this; however, inferring from the first portion of your post try changing all of your Me.Requery entries to:

展开 | 选择 | Wrap | 行号


@Zmbd ...感谢您的回复...并抱歉劫持。


我是Bytes的新手,并习惯了其他会认为这个问题重复的论坛,因为它与我发布问题的初始主题几乎相同。 ..除了那个为那个OP工作的决议对我不起作用。


我也复制并贴在你的身上,不幸的是它仍然没有重新印刷......除非我关闭并重新打开表格。这是最疯狂的事情!
@Zmbd... Thank you for the reply... and sorry for the "Hijacking".

I am new to Bytes, and am used to other forums that would have considered this question a duplicate because it is pretty much the same situation as the initial thread I posted the question on... except the resolution that worked for that OP didn''t work for me.

I copied and pasted in yours as well and unfortunately it still didn''t repaint... unless I close and re-open the form. It''s the craziest thing!


+嗯,我在TBH这里有点亏,所以以下只是我发生的一些事情,没有特别的顺序(除了第一个... :))


+您的代码对控件的on_click事件而不是mouse_down事件。可能没什么区别。如果记录显示为在表单中编辑,则可能导致表单记录设置后端之间的某些断开连接。记录应处于已保存状态。我们可能需要在before_update事件中执行此操作并将cancel设置为true,me.undo,然后在编辑后端后重新查询。


+拆分表单有一些非常不寻常的行为。

为了测试这个,我会根据你的记录源创建一个新的非拆分表单并尝试相同的代码等...如果这种行为再次发生,那么这可能是连接中的一个怪癖。它可能是分裂形式的基本功能,它像定时器事件或Nico5038在旧线程中建议的其他代码一样运行导致问题。


+ A 假设 :因为记录源被打开为只读访问可能太聪明了,并且假设记录集没有变化;因此,当一个人试图重新查询程序时,假定没有任何变化,所以它只是绕过了表单更新。


+似乎偶尔会出现SQL-Server和在更新时访问。我刚刚阅读的一篇文章表明,SQL-Sever端的所有表都有一个时间戳字段,因为Access在提取数据时会使用该字段。


因为您正在直接更改基础记录源,可能是在表单关闭之前,后端中的时间戳没有正确更新。


最好找到一种方法使记录直接可编辑。


+检查默认刷新时间。

Accss2013> ;功能区&​​gt;文件>选项>客户端设置>高级

您可以尝试减少ODBC刷新(手动重新查询应该覆盖此设置)


++在旁注:


Seth(IIRC)在包含空值时Y / N字段存在问题。这确实是Access和SQL-Server之间的一个已知问题,我不相信MS已经解决了。仔细检查此字段中是否没有空值,并将字段设置为不允许空值并具有默认值。

(这篇文章让我想起了这个问题:
五种常见升级对SQL Server的访问权限时的陷阱。这是一篇旧文章;但是,我在其他关于迁移到SQL-Server的博客/文章中一遍又一遍地看到相同的评论。


不用担心在旧线程中发布... Bytes与其他许多站点有不同的感觉。特别是在这种情况下,在之前的线程中找到的旧解决方案没有''为你工作;因此,虽然相关,但这基本上是一个新问题 - 有点像表兄弟是相关的,但不同。
+ Well, I''m at a bit of a loss here TBH so the following are just some things that occur to me in no particular order (other than this first one... :) )

+ your code to the on_click event of the control not the mouse_down event. May not make a difference. If the record is showing as edited in the form this may be causing some disconnect between the form record-set the backend. The record should be in a saved state. We may need to do this in the before_update event and set the cancel to true, me.undo, and then requery once your backend is edited.

+ Split forms have some very unusual behaviors.
To test this I would create a new, non-split, form based on your record source and try the same codes etc... if this behavior reoccurs then this may be a quirk in the connection. It could be the underlying functioning of the split form that is running like a timer event or other code as suggested by Nico5038 in the old thread that is causing the issue.

+ A hypothesis: Because the record-source is being opened as "read-only" Access may be too smart for its own good and assuming that there can be no changes to the record-set; thus, when one attempts to requery the program assumes that there can be no changes so it simply bypasses the form update.

+ There appears to occasionally be a disconnect between the SQL-Server and Access when it comes to updating. One article I''ve just perused suggested that all of the tables on the SQL-Sever side have a timestamp field as Access will use this field when pulling data.

Because you are altering the underlying record source directly, it may be that the timestamp isn''t being properly updated in the backend until after the form is closed.

It would be best to find a way to make the record directly editable.

+ Check the default refresh time.
Accss2013>Ribbon>File>Options>Client Settings>Advanced
You might try reducing the ODBC refresh (manual requery should over-ride this setting)

++ On a side note:

Seth (IIRC) had an issue with the Y/N fields when they contained a null value. This is indeed a known issue between Access and SQL-Server that I don''t believe MS has addressed. Double check that you have no null values in this field and set the field to not allow nulls and to have a default value.
(this article reminded me of that issue:
Five Common Pitfalls When Upgrading Access to SQL Server. It''s an old article; however, I see the same comments over and over again in the other blogs/articles regarding the migration to SQL-Server.

No Worries about the posting in the old thread... Bytes has a different "feel" than many of the other sites. Especially in this case, the old solution found in the prior thread didn''t work for you; thus, although related, this is fundamentally a new question - sort of like cousins are related, yet different.


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

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