简体   繁体   English

访问连续表格-如何个性化每个记录的控件?

[英]Access continuous forms — how to individualize controls per record?

I have an Access form displaying a tiny amount of data for a certain type of record. 我有一个Access表单,它为特定类型的记录显示少量数据。 Basically it just prints the name on the left and on the right has a bunch of Rectangle controls whose background color I change in the form's OnLoad() function, according to results from a query performed using that record's ID as parameter. 根据使用该记录的ID作为参数执行查询的结果,基本上,它只在左侧打印名称,在右侧具有一堆Rectangle控件,这些控件的背景颜色我在窗体的OnLoad()函数中更改。

This all worked fine, got my ID/name on the left and 31 boxes on the right, colored if that day of the month is reserved :) But needless to say that function can be completely arbitrary since it's code. 一切正常,在左侧保留了我的ID /名称,在右侧保留了31个框,如果保留了当月的某天,则将其涂成彩色:)但不用说,该函数可以完全任意,因为它是代码。

Then I decided to switch to 'continuous form' as to display as many records/items as possible. 然后,我决定切换到“连续形式”,以显示尽可能多的记录/项目。 But alas, it was not to be -- all boxes were colored according to the query/function performed for the first record only. 但是可惜的是,并非如此-所有方框都仅根据对第一条记录执行的查询/功能进行了着色。 I figured that might be because it's the OnLoad() but changing it to OnCurrent() did not do much either. 我认为这可能是因为它是OnLoad(),但将其更改为OnCurrent()也没有太大作用。 As it turns out, or that's what I read, the Rectangle intances are shared over the entire form and if I change the BackColor for one of them it changes for that box for each record. 事实证明,或者就是我所读的内容,Rectangle实例在整个表单上共享,如果我更改其中一个的BackColor,则它会为每个记录的该框更改。

I want to be able to change this according to a query performed on a per-record basis. 我希望能够根据对每个记录执行的查询来更改此设置。 Is there any way? 有什么办法吗? Up until now I've only been able to find conditional formatting (the feature that's nor available for rectangles nor seems to cater my exact needs?) and kludgy Access 97 text-box hacks. 到目前为止,我只能找到条件格式(矩形不具备的功能,也不能满足我的确切需求?)和kludgy Access 97文本框黑客。

Thanks in advance :) 提前致谢 :)

You may be coming from an HTML background, where rectangles would be a natural solution. 您可能来自HTML背景,而矩形将是一个自然的解决方案。 They aren't in Access. 他们不在Access中。 I don't think they'll work for you (in fact, "kludgy" could describe the attempt in my humble opinion). 我认为它们不会为您效劳(事实上,“笨拙”可以用我的拙见形容这种尝试)。

You can however display an image. 但是,您可以显示图像。 You'll keep an image for each status ready to call up. 您将保留每种状态的图像以备调用。 I've made visual displays this way. 我已经以这种方式进行了视觉显示。 A little later I may be able to post some code, but I think you'll find this plays out pretty simply even if I don't. 稍后,我也许可以发布一些代码,但我认为即使我不这样做,您也会发现它非常简单。

ADDED NOTE: I'm glad this looks like it will work for you. 补充说明:很高兴这看起来很适合您。 You are concerned about "instanced only once" in your comment below. 您在下面的评论中担心“仅实例化一次”。 Yes, that's true for rectangles which are unbound controls (because they are designed for mere ornamentation). 是的,对于不绑定控件的矩形是正确的(因为它们仅用于装饰)。 But you'll be using an image control which is a bound control (see Remou). 但是您将使用作为绑定控件的图像控件(请参阅Remou)。

All unbound controls in a continuous form will be the same; 连续形式的所有未绑定控件将是相同的; bound controls can be varied using conditional formatting. 绑定控件可以使用条件格式进行更改。

Change each rectangle to a text box, Control Source: 将每个矩形更改为文本框,控制源:

=Iif(myConditionIsMet,"ÛÛÛÛÛ","")

The "Û" is the Full Block character in Arial (asc 219). “Û”是Arial(asc 219)中的完整字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM