只需一小段代码即可获得帮助

编程入门 行业动态 更新时间:2024-10-23 02:41:03
本文介绍了只需一小段代码即可获得帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我只需要一个小mod来代码(我认为)就可以获得我想要的结果。 本周早些时候我收到了FredG的帮助,以便连接一个字段 a表格。我继续在表单中创建一个字段来收集临时的 并置并将其存储到基础表中。我确信这个 打破了一些良好的数据库实践规则,但请相信我,这是必要的 。 我现在想要完成的是测试我想要的两个字段之一 连接以查看它是否为Null,并根据结果显示 store只有一个字段(实例中的NewLongDescription,其他 字段(DefaultHairColor)为Null)或存储连接字段(当 DefaultHairColor不为Null时)。以下是我试图用来实现这个的。我的编码能力相当弱,所以你可能会在我写的内容中看到一个有趣的问题。如果没有,请进一步阅读以获取更多背景信息。 Private Sub NewLongDescription_LostFocus() 如果我!DefaultHairColor IsNull然后 我!NewLongDescription.Requery 我![LongDescription] =我![NewLongDescription] Else 我!NewLongDescription.Requery 我![LongDescription] =我![ConcatDescript] 结束如果 End Sub 在这个新闻组的FredG的指导下,我创建了一个未绑定的 计算表格字段表达式: = [NewLongDescription]& " " &安培; 库存头发颜色(如果有的话): & [DefaultHairColor] 我能够计算(连接)字段。在我的应用程序中我确实需要使这个计算字段成为一个字段,该字段将被记录到底层表格中。。通过一些小编码,我能够完成 。我意识到在大多数情况下这可能不是构建数据库的正确方法,但老实说,在这种情况下它是合适的。 如果你感兴趣,这就是我做的: 当NewLongDescription或DefaultHairColor失去焦点时,现在发生以下 : Private Sub DefaultHairColor_LostFocus() Me!DefaultHairColor.Requery Me![LongDescription] =我![ConcatDescript] 结束Sub $ /> Private Sub NewLongDescription_LostFocus() 我!NewLongDescription.Requery 我![LongDescription] =我![ConcatDescript] 结束子 结果是计算的(未绑定)字段(ConcatDescript)被加载到一个被绑定的字段中的 LongDescription当两个用户 条目字段中的任何一个在更新后失去焦点时(NewLongDescription 或DefaultHairColor)。底线是它迄今为止的工作原理(加载到基础表中的)。现在我希望只有当 DefaultHairColor不为空时才会进行连接。 再次感谢此组的任何输入! ~Bruce

解决方案

" B Love" < BL ******* @ charter>写在 新闻:vu ************ @ corp.supernews:

如果我!DefaultHairColor IsNull然后

可能是IsDull(我!DefaultHairColor) - 莱尔 (电子邮件参考 ffdba /contacts.htm )

Lyle, 谢谢!这就是诡计(除了IsDull评论!)。具体来说, 我使用过: 如果是IsNull(我!DefaultHairColor)那么.............. 再次,非常感谢!现在效果很好! ~Bruce " Lyle Fairfield" <弥************ @ Invalid.Com>在消息中写道 news:Xn ******************* @ 130.133.1.4 ...

" B爱 < BL ******* @ charter>在新闻中写道:vu ************ @ corp.supernews:

如果我!DefaultHairColor IsNull Then

可能是IsDull(我!DefaultHairColor) - Lyle (电子邮件请参考 ffdba/contacts.htm )

" Lyle Fairfield" <弥************ @ Invalid.Com>在消息中写道 news:Xn ******************* @ 130.133.1.4 ...

" B爱 < BL ******* @ charter>在新闻中写道:vu ************ @ corp.supernews:

如果我!DefaultHairColor IsNull Then

可能是IsDull(我!DefaultHairColor)

你是英国人......这种厚脸皮的小伙子,什么!

I just need a small mod to my code (I think) to get the result I want. Earlier this week I had received help from FredG on concatenating a field in a form. I went on to create a field in the form to collect the temporary concatenation and store it to the underlying table. I am certain that this breaks a few rules of good database practices, but believe me, it was necessary. What I am trying to accomplish now is test one of the two fields I wish to concatenate to see if it is Null or not, and based upon the result either store just one field (NewLongDescription in the instance where the other field (DefaultHairColor) is Null) or store the concatenated field (when DefaultHairColor is not Null). Below is what I tried to use to accomplish this. My coding abilities are rather weak, so you might see a fundemantal flaw in what I have written. If not, read further for additional background. Private Sub NewLongDescription_LostFocus() If Me!DefaultHairColor IsNull Then Me!NewLongDescription.Requery Me![LongDescription] = Me![NewLongDescription] Else Me!NewLongDescription.Requery Me![LongDescription] = Me![ConcatDescript] End If End Sub Under the direction of FredG in this Newsgroup, I created an unbound calculating form field with the expression: =[NewLongDescription] & " " & "Stock Hair Color (if any): " & [DefaultHairColor] I was able to make a calculated (concatenated) field. In my application I really needed to make this calculated field a field that would be recorded to the underlying table. With some minor coding, I was able to accomplish this. I realize that in most circumstances this is probably not the proper way to build a database, but honestly, it was appropriate in this case. If you are interested, here is what I did: When either NewLongDescription or DefaultHairColor lost focus, the following now occurs: Private Sub DefaultHairColor_LostFocus() Me!DefaultHairColor.Requery Me![LongDescription] = Me![ConcatDescript] End Sub Private Sub NewLongDescription_LostFocus() Me!NewLongDescription.Requery Me![LongDescription] = Me![ConcatDescript] End Sub The result is that the calculated (unbound) field (ConcatDescript) gets loaded into a bound field called LongDescription when either of the two user entry fields lose focus after an update (NewLongDescription orDefaultHairColor). Bottom line is that it works thus far (is loaded into the underlying table). Now I want the concatenation to take place only if DefaultHairColor is not Null. Thanks again for any input from this group! ~Bruce

解决方案

"B Love" <bl*******@charter> wrote in news:vu************@corp.supernews:

If Me!DefaultHairColor IsNull Then

probably IsDull(Me!DefaultHairColor) -- Lyle (for e-mail refer to ffdba/contacts.htm)

Lyle, Thanks! That did the Trick (except for the IsDull comment!). Specifically, I used: If IsNull(Me!DefaultHairColor) Then .............. Again, thanks so much! It works great now! ~Bruce "Lyle Fairfield" <Mi************@Invalid.Com> wrote in message news:Xn*******************@130.133.1.4...

"B Love" <bl*******@charter> wrote in news:vu************@corp.supernews:

If Me!DefaultHairColor IsNull Then

probably IsDull(Me!DefaultHairColor) -- Lyle (for e-mail refer to ffdba/contacts.htm)

"Lyle Fairfield" <Mi************@Invalid.Com> wrote in message news:Xn*******************@130.133.1.4...

"B Love" <bl*******@charter> wrote in news:vu************@corp.supernews:

If Me!DefaultHairColor IsNull Then

probably IsDull(Me!DefaultHairColor)

You Britishers... such cheeky chaps, what!

更多推荐

只需一小段代码即可获得帮助

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

发布评论

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

>www.elefans.com

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