VBA Code - Checkbox - Label problem

JPW

Registered User.
Local time
Today, 09:35
Joined
Nov 4, 2007
Messages
51
I'm in a bit of a mess...

Okay, I have some VBA code that causes a label on my main form to change depending on the value that is in the check box in the record.

The idea:

The idea of part of my form is for the user to have to check a tick box to know that the 'thing' can be released. It's to make the user more aware. All 'things' are asumed to be in the category of 'Can't be released' until notified and the user checks the box in the form and thus the VBA should change the content of the label.


Existing Code:
Code:
Private Sub tickrelease_AfterUpdate()

    If Me.tickrelease = True Then
    Me.lblrelease.ForeColor = vbGreen
    Me.lblrelease.Caption = "Can be released"
Else
    Me.lblrelease.ForeColor = vbRed
    Me.lblrelease.Caption = "Can't be released"
End If

End Sub

The default value of the check box when a new record is created is no tick in the box, and default caption of the 'lblrelease' is "Can't be released", with the same red that is indicted in the code above.


The Problem:
The code to cause the label to change color/text does work to a degree. For example - if the check box is ticked then the text and color in the label will change to, and if there's no check in the check box then different color and text appears.

However, what I have noticed is that the label change doesn't stay bound to that record when browsing through the records on the form or creating a new record the colours from the previous record stays with the label into the next new record or new browsed record (the checkboxes themselves stay bound to the form/record and work fine - no problem with that) it just seems the content of the labels isn't working properly as I intented and would like the changes in the label caused by the text box to stay bound to that record.

I hope you guys understand. If not I can upload the database that can show you guys the problem.

Thanks for any help you may give.
 
If you're in a single view form, you should be able to add the same code to the current event.
 
If you're in a single view form, you should be able to add the same code to the current event.

i shall try that, and keep the code in the after update too? What do you mean by single view form?

This form will be accessible or will be accessible to up to 4 users on 4 pc's over the lan network.

I shall try your recommendation and get back to this thread to resport on results. Thank you.
 
Yes, keep the code in the after update event too. The current event will handle when you change records, the after update event will handle changing the value. By single view I meant your form only shows 1 record at a time, as opposed to continuous or datasheet view. In those views, I'd use Conditional Formatting, though you wouldn't be able to change the caption.
 
Thank you so much - that code works perfectly in my database.
 
The above code works perfectly on the form side of things, but now I have created a report in Access and I have all the fields in and all formatted to my vision I have a new problem that may require VBA code to fix.

In my previous post above I talk about a check box, and it's this check box I'm having problems with in word. The correct data is showing in the check box on the form depending on what record I've chosen to appear on that record so no problem with that. However, I want the label to change to and not sure how to do that.

Basically, I need a mechanism in the report for the label in the report to change depending on the value in the check box.

Thanks for assistance.
 
Try similar code in the format event of the section containing the label (detail section I assume).
 
once again, thank you that works fine :)
 

Users who are viewing this thread

Back
Top Bottom