控件处于活动状态时,文本框数据传输不会更新 [英] Textbox Data Transfer not updating when control is active

查看:59
本文介绍了控件处于活动状态时,文本框数据传输不会更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在''main''表单中的子表单之间自动将数据从一个文本框传输到另一个文本框。我将此代码放入Gotfocus事件过程中:


Private Sub Date_GotFocus()

如果Len(修剪$(我![Date Fish] .Value& ""))= 0然后

''这会检查空白或空格填充的日期字段 - 它只会在尚未输入的情况下传输数据。

Me![日期鱼] = [表格]![主要数据收集表格]![现场数据收集子表格]。[表格]![水]。[表格]![日期]


SendKeys" {F2}"

SendKeys" {TAB}"

SendKeys" + {TAB}"

结束如果

结束子


它有效 - 在某种程度上。 Sendkeys部分正在尝试显示数据。它只会在我移动到另一个控件或子窗体时显示出来。


但这不是我想要的方式 - 也许我根本就没有这么做。


我输入日期在一个子表单中(水 - 总是为该记录收集数据)


然后我移动到另一个子表单(Fish,其中仅为某些记录输入数据) 。大多数情况下,日期将是相同的 - 但并非总是如此。因此,当我进入日期文本框时,我希望日期来自水。进入盒子。然后,如果它不同,我可以编辑它,否则它''默认''到'水'日期。


有没有办法做到这一点?我尝试定义默认值,但没有成功 - 也许我没有正确完成。


真正的问题是只有在该子表单中输入数据时输入日期。如果没有输入数据,那么也不应该输入日期 - 这意味着我不能简单地在水日期子表单中的松散焦点上填充所有子表单日期。


嗯?

I am trying to automatically transfer data from one textbox to another between subforms within a ''main'' form. I put this code into the Gotfocus eventprocedure:

Private Sub Date_GotFocus()
If Len(Trim$(Me![Date Fish].Value & "")) = 0 Then
''This checks for blank or space-filled date field - it will only transfer data if it has not already been entered.

Me![Date Fish] = [Forms]![Main Field Data Collection Form]![Field Data Collections Subform].[Form]![Water].[Form]![Date]

SendKeys "{F2}"
SendKeys "{TAB}"
SendKeys "+{TAB}"
End If
End Sub

It works - to an extent. The Sendkeys parts are trying to get the data to show up. It only shows up when I move to another control or subform.

But this is not how I want this to work - and maybe I am not doing this correctly at all.

I enter a date in one subform ("Water" - where data is always collected for that record)

Then I move to another subform ("Fish" where data is only entered for some records). Most often the Date will be the same - but not always. So when I move into the date textbox, I want the date from "Water" to move into the box. Then if it is different, I can edit it, otherwise it is ''defaulted'' to the ''Water'' date.

Is there a way to do this? I tryed defining the default value, but did not have success - perhaps I did not do it correctly.

The real problem is having the date entered only if data is entered in that subform. If no data is entered, then the date should not be entered either - That means I can not simply populate all the subform dates upon ''Loosing focus'' in the ''Water'' date subform either.

Hmmmm?

推荐答案

(我![Date Fish] .Value&""))= 0然后

''这会检查空白或填满空格的日期字段 - 它只会在尚未输入的情况下传输数据。


Me![Date Fish] = [表格]![主要现场数据收集表格]![现场数据收集子表格]。[表格]![水]。[表格]![日期]


SendKeys" {F2}

SendKeys{TAB}"

SendKeys" + {TAB}"

结束如果

结束子


它在某种程度上有效。 Sendkeys部分正在尝试显示数据。它只会在我移动到另一个控件或子窗体时显示出来。


但这不是我想要的方式 - 也许我根本就没有这么做。


我输入日期在一个子表单中(水 - 总是为该记录收集数据)


然后我移动到另一个子表单(Fish,其中仅为某些记录输入数据) 。大多数情况下,日期将是相同的 - 但并非总是如此。因此,当我进入日期文本框时,我希望日期来自水。进入盒子。然后,如果它不同,我可以编辑它,否则它''默认''到'水'日期。


有没有办法做到这一点?我尝试定义默认值,但没有成功 - 也许我没有正确完成。


真正的问题是只有在该子表单中输入数据时输入日期。如果没有输入数据,那么也不应该输入日期 - 这意味着我不能简单地在水日期子表单中的松散焦点上填充所有子表单日期。


嗯?
(Me![Date Fish].Value & "")) = 0 Then
''This checks for blank or space-filled date field - it will only transfer data if it has not already been entered.

Me![Date Fish] = [Forms]![Main Field Data Collection Form]![Field Data Collections Subform].[Form]![Water].[Form]![Date]

SendKeys "{F2}"
SendKeys "{TAB}"
SendKeys "+{TAB}"
End If
End Sub

It works - to an extent. The Sendkeys parts are trying to get the data to show up. It only shows up when I move to another control or subform.

But this is not how I want this to work - and maybe I am not doing this correctly at all.

I enter a date in one subform ("Water" - where data is always collected for that record)

Then I move to another subform ("Fish" where data is only entered for some records). Most often the Date will be the same - but not always. So when I move into the date textbox, I want the date from "Water" to move into the box. Then if it is different, I can edit it, otherwise it is ''defaulted'' to the ''Water'' date.

Is there a way to do this? I tryed defining the default value, but did not have success - perhaps I did not do it correctly.

The real problem is having the date entered only if data is entered in that subform. If no data is entered, then the date should not be entered either - That means I can not simply populate all the subform dates upon ''Loosing focus'' in the ''Water'' date subform either.

Hmmmm?


您应该将它放在Before Update事件中,并且您在子窗体上查找日期的语法是错误的。


如果[Date Fish]不是日期/时间数据类型,它应该是。然后你只需要检查空值。


我还建议您将Water子窗体中的字段名称从Date更改为其他内容,因为Date是Access中的一个函数。

You should put this in the Before Update event and your syntax for finding the date on the subform is wrong.

If [Date Fish] is not a Date/Time data type it should be. Then you only have to check for null value.

I would also suggest you change the name of the field in Water subform from Date to something else as Date is a function in Access.

展开 | 选择 | Wrap | 行号


我们要......形式![水] .Form![日期]?

我会想到的......表格![水]。[日期]

格式是否正确?

(看我正在学习新东西 - 一周前即使问这个问题,我也不会有任何线索)
Do we want ...Form![Water].Form![Date]?
I would have thought ...Form![Water].[Date]
would be the correct format?
(See I''m learning new stuff all the time - a week ago I wouldn''t have had a clue even to ask the question)


这篇关于控件处于活动状态时,文本框数据传输不会更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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