473,836 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

refering to a field in a 'multiple items' form

reginaldmerritt
201 New Member
i wish to change the backcolor of a field on a current record being dispalyed in a 'multiple items' form. However when using me.fieldname01. backcolor = makes refrence to all fields called fieldname01 on the 'multiple items' form and therefore all fields change colour not just the current record.

How do i refer to the current record with field named fieldname01?

Thanks :)
Dec 14 '07 #1
10 9170
FishVal
2,653 Recognized Expert Specialist
Hi, Reginald.

I guess you mean Datasheet or Continuous forms view.
You may use conditional formatting to achieve this.
  • a special conditional format type is "control has focus"
  • you may use additional bound checkbox control to trigger conditional formatting (sure that means you need to add this field to the form's bound table)
    in format condition
    Expand|Select|Wrap|Line Numbers
    1. Forms!frmFormName!chkMark=True
    2.  
    in form's module
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_BeforeUpdate(Cancel As Integer)
    2.     'to clear previous record mark
    3.     Me.chkMark = False
    4. End Sub
    5.  
    6. Private Sub Form_Current()
    7.     'to check current record mark if it is not new one
    8.     If Not Me.NewRecord Then Me.f3 = True
    9. End Sub
    10.  

Regards,
Fish
Dec 14 '07 #2
reginaldmerritt
201 New Member
thanks for your reply Fish

your quite right i have the form in continues form view. I have a check box on the form which is bound. When this check box is clicked i what all the fields in that perticular record to change color, a way of highlightin a chosen record. Lets just say it is called chkMark.

I'm a bit thrown by the code you showed, i was knida hoping there was a currentrecord. rahter than a me. that i could use.

I don't understand how the code you mentioned achives this. and i'm very confused what me.f3 means.
I tried putting
Expand|Select|Wrap|Line Numbers
  1.  if chkMark=True then me.fieldname01.backcolor = 255
in form_current but that doesn't do anything.

Sorry if i'm gettin the wrong end of the stick, or not explaning myself well.
Dec 14 '07 #3
FishVal
2,653 Recognized Expert Specialist
Hi, Reginald.

Ok. Below is a fixed code with some explanations.

Expand|Select|Wrap|Line Numbers
  1. 'BeforeUpdate event fires when a current record looses focus
  2. 'the code clears chkMark so conditional format makes the control looks like 
  3. 'inactive record
  4. Private Sub Form_BeforeUpdate(Cancel As Integer)
  5.     'to clear previous record mark
  6.     Me.chkMark = False
  7. End Sub
  8.  
  9. 'Current event fires when form controls are populated with current record values
  10. Private Sub Form_Current()
  11.     'to check current record mark if it is not new one
  12.     If Not Me.NewRecord Then Me.chkMark = True
  13. End Sub
  14.  
The following expression should be placed in a control needed to change its appearance conditional format condition. As well as comparisson type should be set to "Expression is" and background color to what you like.
Expand|Select|Wrap|Line Numbers
  1. Forms!frmFormName!chkMark=True
  2.  
To understand how the code works toggle breakpoints on each sub and see when they are invoked.
Dec 14 '07 #4
NeoPa
32,584 Recognized Expert Moderator MVP
Reginald, if you think about what you're asking it to do you will see that it doesn't actually make sense (this is possibly only comprehensible if you understand what's going on under the hood of course).
The control that you're accessing is actually a single object that is reused as separate instances for each record displayed on the form. When you change the design of the control, you do just that. Change the design of the control which is used for each instance. Instances are not even perpetuated when they are no longer visible on the form, so the practicalities of changing the settings at an instance (record) level are further complicated.

Hence the recommended way to handle a situation like this is to design conditional formatting into the control itself. This way the data determines the formatting and consistency is maintained after scrolling or rebuilding the query.
Dec 14 '07 #5
reginaldmerritt
201 New Member
Ah i see, not a smiple as i hoped, but i understand why now. thanks NeoPa.

Thanks for the clearer explination Fish, i appreciate your time.

I see how it will show which record is current and would highlight the current record. Which is simular to using "When Field Has Focus" under Condintonal Formating for that control. Or atleast that is what the code does for me.

What i'm actually after is a way to have a check box for the user to choose to turn on or off a backcolor to the control, which will then stay that colour for that record even after the database has been shutdown and reopened. This is so the user can look at a number of records and pick out the ones they have marked easily.

Which isn't really possible, but where there's a will there's a way.
Dec 14 '07 #6
NeoPa
32,584 Recognized Expert Moderator MVP
What about an underlay control with the same ControlSource as the CheckBox.
With conditional formatting you could set this control to the colour of your choice. After that, all you have to do is set the other control on top of it with a transparent background. Could that do the trick for you?
Dec 14 '07 #7
reginaldmerritt
201 New Member
What about an underlay control with the same ControlSource as the CheckBox.
With conditional formatting you could set this control to the colour of your choice. After that, all you have to do is set the other control on top of it with a transparent background. Could that do the trick for you?
Yeah good idea NeoPa i did think of that. I put a text box under the cotrols i wished to highlight, i set the texcolour to white and the background to white. The checkbox gave the text box a value which i used in contional formating for the text box as' field value is' which turned the backgorund and text colour to yellow.

Unfortunatly the contional formating only seems to apply when directly entering the value and pressing enter. After closing the form and reopening the contional formating did not react and the text box with the correct field value to change colour stayed white unless i gave the control focus and pressed enter again.

Is the a way of running a condional value on a control, like a requery code or something? Or giving focus to a control and make access think you've pressed enter?
Dec 18 '07 #8
NeoPa
32,584 Recognized Expert Moderator MVP
I think your problem is more likely related to setting the "Back Color" to White (16777215) instead of setting the "Back Style" to Transparent.
Dec 18 '07 #9
reginaldmerritt
201 New Member
I don't know why but it seems to work now.

I added a new bound text control which is set to be behind all other controls and have the same color background as the forms background so you can't see it.

The bound option check box changes the new hiden text control to have the value "a".

The new hiden text control has condtional formating that turns it yellow when equal to "a".

Many Thanks to Fish and NeoPa for helping me work though this.
Dec 18 '07 #10

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

Similar topics

2
2876
by: perplexed | last post by:
Is there a way to combine the values of multiple form items such as two textboxes and one radio button for insertion into one MYSQL database field?
1
8952
by: Keiron Waites | last post by:
Hi, I have two select fields with the multiple attribute so you can see all options. When a user clicks on one form, I would like to deselect anything from the other form. Is there a way to do this? eg document.forms.form.list1.selectedIndex='NULL'; ? Where can I find out about all options with regards to the DOM? Thanks,
12
8905
by: Forti2ude | last post by:
Hello, I have a simple form... <form> <select name="foo" multiple> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select>
2
6610
by: Jen F. | last post by:
I have inherited a medical database in which there are multiple values stored in a single field (ie. "Current Conditions" field might contain 1-20 different conditions, separated by comma (ie. "Heart Disease,Hyper Tyroid,Cancer" etc. I would like to search via combo box for any one or more than one value in this field, ie-what patients have Heart Disease or Cancer by selecting these disorders off the combo box list. Any help would be...
4
2360
by: Onion | last post by:
This has to be simple, but I'm forced to admit that I'm a novice who can't figure it out. I have a listbox in a form that allows multiple selections. That works fine. The problem: I can't figure out how to store the data. I want to store the items chosen from the listbox in a field for the current record. That means the table field must store the variable number of text items selected from the listbox by the user.
3
1844
by: Kranman | last post by:
Hi All, Love this site, have gotten a lot from it. This is my first time posting though, so forgive me for any errors. I have an Access 2000 db where I have a main form of Contractors and on the main form is a subform of bonds carried by those contractors. I am trying to reference a field named "Bond" located on the subform in code that is run from the mainform and am having trouble with the syntax for this. Below is a sample of...
2
2278
by: Peter | last post by:
Hello! Please, could anyone tell, is it possible to set multiple items to be selected in list control in the code? For example when the web form is loaded three items of 5 are selected in list control already? Now I manage to set only one item to be selected during page load, but there is need to multiple items could be selected for the user. I appreciate very much your help! Thanks.
1
1380
by: adampope | last post by:
Hi Access boffins, I've a form that I want to give users the option of choosing whether certain fields are visible or not. So I've created a table mirroring the original table called tblVisibleFields, and a form with loads of checkboxes on it. Then, in the main form, I've put the following code: Private Sub Form_Activate() If Tables!tblVisibleFields!ProjectNumber = True Then
25
5414
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. Basically i have a multiple select box. An it works except for this one part i want to add to it.The first box i have is called project members which shows the users you can choose to send an email to and the other box is called assignees which is the...
0
9671
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
10551
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
10595
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
9379
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7793
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
5650
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
5828
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4021
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.