By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,176 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

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

P: 8
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
Share this Question
Share on Google+
3 Replies


missinglinq
Expert 2.5K+
P: 3,532
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

P: 8
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

P: 8
All sorted, works perfectly! Thank you!!

:)
Aug 15 '08 #4

Post your reply

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