469,646 Members | 1,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

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


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!


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()
  3.  If Me.DNR = -1 Then
  4.   Me.Section(acDetail).BackColor = vbRed
  5. Else
  6.   Me.Section(acDetail).BackColor = 16777215
  7. End If
  9. End Sub
Aug 15 '08 #1
3 2304
3,532 Expert 2GB
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
Crumbs, that was quick! I will give it a go this evening and let you know how I get on. Thank you!!

Aug 15 '08 #3
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.

Similar topics

2 posts views Thread by Colin McGuire | last post: by
1 post views Thread by sdavis1970 | last post: by
16 posts views Thread by Phil Stanton | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.