Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Programming in Access or VB

  • 30-01-2006 03:40PM
    #1
    Registered Users, Registered Users 2 Posts: 1,832 ✭✭✭


    Hi,

    Having a problem with an accesss database. Basically I have a form with many records in it. I want to have a button which changes the background color of a certain field, but I only want the field to change color for the specific record that I am in.

    If I use field.backcolor = vbGreen in the button properties, it changes this field in every record to Green, but I only want the current record to change.

    Any thoughts.

    Thanks.


Comments

  • Moderators, Politics Moderators, Paid Member Posts: 44,064 Mod ✭✭✭✭Seth Brundle


    whats the name of the field?
    try
    fieldname.backcolor = vbGreen


  • Registered Users, Registered Users 2 Posts: 1,832 ✭✭✭careca


    kbannon wrote:
    whats the name of the field?
    try
    fieldname.backcolor = vbGreen

    Hi,

    Maybe I should have stated this is a subform, with loads of records. If I put that code behind the button it will change the colour for all of the records in that subform. Ie if its notes.backcolor = vbGreen then the field 'notes' in all records will change background color.

    I only want the field 'notes' in the current record (or whichever one I click the button) to change.

    Thanks for reply.


  • Moderators, Education Moderators, Motoring & Transport Moderators Posts: 7,396 Mod ✭✭✭✭**Timbuk2**


    I think this should do it

    notes(0).BackColor = vbGreen

    A bit like an array, it is 0-based, so that will change the first field to green, and

    notes(1).Backcolor = vbGreen

    would change the second field

    If you wanted to change the first 5 at once you would do this in a loop:

    Dim i%
    For i 0 To 4
    notes(i).BackColor = vbGreen
    Next

    Hope this helps


Advertisement