473,796 Members | 2,538 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.BackStyle Missing

NeoPa
32,579 Recognized Expert Moderator MVP
I have a project I'm working on where I want to disable editing on a form in certain circumstances. To avoid confusing the operator, I would like to change the appearance of the form so that is visually different between the two modes. A sort of visual clue if you like.

I developed the following code, but I find that this won't compile (to my surprise) :
Expand|Select|Wrap|Line Numbers
  1. Private Sub chkLocked_AfterUpdate()
  2.     Dim ctl As Object     'Same problem if done As Control
  3.  
  4.     With Me
  5.         .AllowEdits = (Not .chkLocked)
  6.         For Each ctl In .Detail.Controls
  7.             .BackStyle = .chkLocked
  8.         Next ctl
  9.     End With
  10. End Sub
The error message is "Method or data member not found" and the .BackStyle on line #7 is highlighted (yellow).

Does anyone have any explanation? I have checked various of the controls (TextBox; Label; ComboBox; CheckBox) and only CheckBox doesn't have this property.
Jun 6 '09 #1
12 4544
FishVal
2,653 Recognized Expert Specialist
Hi, NeoPa.

Your code invoke BackStyle property of current form.
Compiler knows that since it knows type of Me object.
Jun 6 '09 #2
OldBirdman
675 Contributor
Why not change the form's .BackColor ? I use 3 colors 1)View, 2)Edit, 3)New/Adding to provide this visual clue. I use another set of 3 colors if form is filtered, to avoid frustration of not finding a record that is known to exist.
Jun 6 '09 #3
NeoPa
32,579 Recognized Expert Moderator MVP
@FishVal
It seems kicking myself is a recurring theme today :(

At least it got me to look at why the Form object doesn't have such a property (I expected it should). It turns out that the various sections of the form (Header; Detail; Footer; etc) have the property (which shows the colour of the form if - as in my case - they are always set the same).

Thanks for being a reliable pair of eyes Fish :)
Jun 6 '09 #4
NeoPa
32,579 Recognized Expert Moderator MVP
@OldBirdman
I'm giving this some careful consideration OB.

It's always harder to change direction midstream, but this idea seems to have such promise that I may take it up (or a version of it at least). With my character unfortunately, it pretty well means revisiting all my old code to bring those up to spec. I may get away without the third colour, but I also like your filtering idea.

I will have to go away and cogitate on it for a bit.

Thank you for this idea :)
Jun 6 '09 #5
ADezii
8,834 Recognized Expert Expert
NeoPa makes a valuable point in Post #4, whereas you can programmaticall y set the BackColor Property of individual Form Sections, as in:
Expand|Select|Wrap|Line Numbers
  1. Forms!Orders.Section(acDetail).BackColor = QBColor(9)
  2. Forms!Orders.Section(acHeader).BackColor = QBColor(10)
  3. Forms!Orders.Section(acFooter).BackColor = QBColor(11)
  4. Forms!Orders.Section(acPageHeader).BackColor = QBColor(12)
  5. Forms!Orders.Section(acPageFooter).BackColor = QBColor(13)
  6.  
Jun 7 '09 #6
NeoPa
32,579 Recognized Expert Moderator MVP
Indeed ADezii, but unfortunately the .Section property, even though it appears to be an array or collection, does not seem to support the For ... Each construct.

Any tips or clues on that one would be helpful. My current code includes :
Expand|Select|Wrap|Line Numbers
  1. With Me
  2.     lngColour = IIf(.chkLocked, conEditNo, conEditYes)
  3.     .FormHeader.BackColor = lngColour
  4.     .Detail.BackColor = lngColour
  5.     .FormFooter.BackColor = lngColour
  6. End With
This works fine, but itemising each section like this seems pretty messy to me :(
Jun 7 '09 #7
ADezii
8,834 Recognized Expert Expert
@NeoPa
.Section property, even though it appears to be an array or collection, does not seem to support the For ... Each construct.
  1. The For...Each Construct requires that you iterate through various Objects contained within their respective Collection, usually the plural of the Object's Name (Control...Cont rols, TableDef...Tabl eDefs, etc.). Unfortunately, to the best of my knowledge, a Sections Collection does not exist, ergo (you like that?), you cannot iterate a Collection that simply isn't there. Here is syntax, however, that you use:
    Expand|Select|Wrap|Line Numbers
    1. Dim sec As Section
    2.  
    3. Set sec = Forms!Orders.Section(acDetail)
    4.  
    5. sec.BackColor = QBColor(4)
    6.  
  2. You could also:
    Expand|Select|Wrap|Line Numbers
    1. On Error Resume Next
    2. Dim intSectionCounter As Integer
    3. Randomize
    4.  
    5. For intSectionCounter = 0 To 4
    6.   Me.Section(intSectionCounter).BackColor = QBColor(Int(Rnd * 16))
    7. Next
Jun 7 '09 #8
FishVal
2,653 Recognized Expert Specialist
Oh, ye. Access object model doesn't have any method or property which gives reference to "Sections" collection.
Sure it could be easily obtained with a simple reusable global function like the following.

Expand|Select|Wrap|Line Numbers
  1. Public Function FormSections(frm As Access.Form) As VBA.Collection
  2.  
  3.     Dim col As New VBA.Collection
  4.  
  5.     On Error Resume Next
  6.  
  7.     For i = 0 To 4             'sections with indexes 0 to 4 are available in form
  8.         col.Add frm.Section(i), frm.Section(i).Name
  9.     Next i
  10.  
  11.     Set FormSections = col
  12.  
  13. End Function
  14.  
Then in form module:
Expand|Select|Wrap|Line Numbers
  1. .....
  2.     For Each obj In FormSections(Me)
  3.         .....
  4.     Next
  5. .....
  6.  
The same function could set Section.Backcol or in accordance with additional argument(s) and/or global settings and/or predefined form properties.

Ultimately, if high level of tuneability is required, then it could be implemented as custom class or a part of existing (if existing) class extending Access.Form class functionality.
Jun 7 '09 #9
ADezii
8,834 Recognized Expert Expert
@FishVal
  1. Hell FishVal, I'm just confused on 1 point so kindly point me in the right direction. If I understand you correctly, the Public Function is returning a Collection of Form Section Objects, so couldn't Line #8 above simply be:
    Expand|Select|Wrap|Line Numbers
    1. col.Add frm.Section(i)
  2. And any Reference to these Objects could be obtained via something similar to:
    Expand|Select|Wrap|Line Numbers
    1. Dim obj As Object
    2.  
    3. For Each obj In FormSections(Me)
    4.    Debug.Print obj.Name, obj.BackColor, obj.Height, ...
    5. Next
  3. I thank you in advance for your explanation in this matter.
  4. Very interesting and informative Comments, as is always the case from you.
Jun 7 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
1685
by: Steven T. Hatton | last post by:
If you happen to have Accelerated C++ by Koenig and Moo, and haven't gotten around to reading it, I suggest you count the pages between page 18 and page 51. I came up with zero. This is very disappointing since I have been intending to read the book for some time now. I finally picked it up with the expectation that I would breeze through it as a review and an alternative expert perspective on C++. Now it looks as though I will have to...
7
5393
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available from clicking on many of the available topics (mostly methods but some properties are also unavailable). This same problem occurs with many, if not most, keywords. Is there any way I can activate these "missing" help topics? HELP!
102
5722
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler can't tell where a bracket is missing.... a few weeks have past, I requested a feature for the delphi ide/editor "automatic identation of code in begin/end statements etc" and today when I woke up I suddenly released a very simple solution for this...
0
3097
by: kris | last post by:
hi can any one help me out, i have written a code for Word Indexing using Dll's i think this is an incomplete code for WORD INDEX. I had encountered this error "Error! No index entries found" when i opened word document can any one fill out the missing code with this.
17
3036
by: Justin Emlay | last post by:
I'm hopping someone can help me out on a payroll project I need to implement. To start we are dealing with payroll periods. So we are dealing with an exact 10 days (Monday - Friday, 2 weeks). I have a dataset as follows (1 week to keep it short): Employee 1 - Date 1 Employee 1 - Date 2
3
2128
by: JD | last post by:
Is it possible to have a clear backstyle for a lable control? I want to write some text on a lable and I want the background of the label to match the color of the control I am placing the label on where the color of that control will be changing will be changing. Is this doable? If not, is there a control I can do this with? to have a clear/see through backstyle? Thanks, JD
0
1688
by: youth | last post by:
I am trying to bind the DB2 utlities to a new database that was created by our DBAs. Each time I try I get the following: db2ajgrt.bnd - No errors db2clish.bnd - 13 errors all for missing package SQLABD01 db2clisn.bnd - 13 errors all for missing package SQLABD01 db2clibh.bnd - 13 errors all for missing package SQLABD01 db2clibn.bnd - 13 errors all for missing package SQLABD01 db2cliv2.bnd - 2 errors both for missing package SQLABD01...
3
2833
by: Fred Chateau | last post by:
Still working on my XML DataSet... Having moved on past difficult and complex problems, resolved with the assistance of everyone here, I find myself facing yet another problem. My XML document breaks the schema. There are missing tags everywhere, on purpose I'm told, because we don't need them. I'm getting a "System.Data: There is no row at position <row number>" error. Hopefully I can workaround this issue. I need to find a way to...
0
1243
by: Wayne | last post by:
The tab control "backstyle" property refuses to work when set to "transparent" in an A2003 database if Windows themes controls are being used. I've seen references to this in a few places, but no fix. If the A2003 database is opened using A2007 the property works fine. Go figure. Does anyone know of a workaround?
0
9684
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10236
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10182
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10017
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7552
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5445
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.