Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Programming in Access or VB

Options
  • 30-01-2006 3:40pm
    #1
    Registered Users 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 Posts: 38,972 Mod ✭✭✭✭Seth Brundle


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


  • Registered Users 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,395 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