473,725 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access form - changing and saving a record's background colour on button click

8 New Member
Hi

I'm new to the forum and also a VERY new user of Access to develop databases. I'm building a DB for a driving instructor acquaintance, and he wants a button on the pupil data entry form which he can click to flag a pupil as "Do Not Rebook" (i.e. if they're a non-payer or something). Upon clicking the button, he wants a value to be recorded in the appropriate field in the table (so we can report on it later) and he also wants the background of the entire record to turn red.

i've created the toggle button on the form and when I click it, it records a value in the table to which the form is bound (the data type is set to on/off). So far so good. I then browsed this forum and managed to find some code which i adapted (probably very badly!!) to make the background colour of the form change to red at the time the button is clicked. However, what happens when I click is that the background colour is then changed on ALL the records in the form, rather than just the one I'm interested in. It also doesn't remember the formatting if I exit and go back into the form. This is important as he wants an instant visual reminder not to rebook certain individuals.

Is it possible to restrict the background colour change to just one record, and to get Access to remember this for next time?

I've posted the code I've got so far below plus some info on the field names/form name. I really am a total novice so I hope I've put enough info - any help much appreciated!

Thx
=:o*

Code below is attached to On Click Event Procedure of a toggle button bound to DNR field in t_Pupils. Button itself is on form f_Pupils, bound to t_Pupils

Expand|Select|Wrap|Line Numbers
  1. Private Sub DNR_Click()
  2.  
  3.  If Me.DNR = -1 Then
  4.   Me.Section(acDetail).BackColor = vbRed
  5. Else
  6.   Me.Section(acDetail).BackColor = 16777215
  7. End If
  8.  
  9. End Sub
Aug 15 '08 #1
3 2627
missinglinq
3,532 Recognized Expert Specialist
If this is a Single View Form, i.e. if you can only view one record at a time, you simply need to palace the same code in the Form_Current event.

Welcome to Bytes!

Linq ;0)>
Aug 15 '08 #2
bettyboo
8 New Member
Crumbs, that was quick! I will give it a go this evening and let you know how I get on. Thank you!!

=;o*
Aug 15 '08 #3
bettyboo
8 New Member
All sorted, works perfectly! Thank you!!

:)
Aug 15 '08 #4

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

Similar topics

2
3104
by: Terry | last post by:
Hello, I wonder if anyone can shed light on this problem for me. I have an Access 97 front end with an SQL 2000 database. There is a Business main form with an Owner subform and corresponding tables of the same names. A third table BusinessRel records the BusinessID (linked to Business table) and OwnerID (linked to Owner table). This is what happens when the Business main form is loaded. I enter the BusinessID and other stuff, then as...
16
7233
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
2
1189
by: Colin McGuire | last post by:
Hi, according to the on-line documentation you can change the background colour of, for example a button, to Gray as shown below. Dim b as Button b.BackColor=Color.Gray If I programmatically want to change the background colour of a button to the default background colour for controls, it may or may not be grey (depending on the preferences, eg Windows Classic style vs. Windows XP style or a customised style may have changed the...
13
3991
by: royaltiger | last post by:
I am trying to copy the inventory database in Building Access Applications by John L Viescas but when i try to run the database i get an error in the orders form when i click on the allocate button "Unexpected Error":3251 operation is not supported for this type of object.The demo cd has two databases, one is called inventory and the other just has the tables for the design called inventory data. When you run inventory the database works...
2
6253
by: Frav | last post by:
The Reps team have been experiencing that Access 2002 unexpectedly quits while working and also lots of Corruption Failures and "Record lock can not update" messages since the upgrade from Windows 2000 and Access 200 to Windows XP and Access 2002 (XP) was done. Now, they are working and at anytime in anywhere of the application access unexpectedly quits with no error messages and the info that was being entered
1
3039
by: sdavis1970 | last post by:
I am working on an Access 2002 database where one of the tables has five required fields making up the key. There is a form that is linked to this table which is used for adding new records. There is a close button on this form that has the following code in it's OnClose event: "DoCmd.close"
16
5182
by: Phil Stanton | last post by:
I have a form with a button which is supposed to open an Excel file (With lots of Macros /VBA) in it. The Excel file gets it's data from the Access program Here is the code Private Sub Storage_Click() On Error GoTo Err_Storage_Click
3
1849
by: alex091088180189 | last post by:
Hi all sorry if this has been answered but on a tight schedule so haven't got time to search I'm making a database to record and refer results to several tests in a unit of exams. There are 8 available units each with 4 possible tests. now this isn't a necessity but in order to make things easier for us to admin the database I want to put in a few little functions. before I start - I'm using access 2007, and the database is set up so...
2
19482
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
8752
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
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
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...
0
9111
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...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4517
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...
1
3221
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
2
2634
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
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.