Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a Label Visible on one record in a continuous Form 1

Status
Not open for further replies.

WallT

Vendor
Aug 13, 2002
247
US
I am using a continuous form to show videos in stock, and I have a label that says "Available" and another label that say's "Currently out of stock". I am using the following If/Then statement to decide which label to show:

If Me.chkAvailable = True Then
Me.lblAvailable.Visible = True
Me.lblOOStock.Visible = False
Else
Me.lblAvailable.Visible = False
Me.lblOOStock.Visible = True
End If

My question is, how can I get this to work on a single record in a continuous form instead of it effecting each record on the form. I hope I am making sense, and that it is possible. I am using it under the 'OnCurrent' event. Thanks for any help.



 
That should work on a continuous form. Make sure the code is in the Current Event for the Form.

Paul
 
It is changing every records labels, not just the record with the If/Then criteria. In other words, if one record is "Currently on Loan" then it shows them all as "Currently on loan". I am not that experienced, so I hope I am explaining this correctly. Also, it is a ReadOnly form. No adding or editing. There is just a command button that you can click to open another form.
 
Sorry, I'm a dumb___. I never changed my form to continuous. I was looking at it in Single Form View. The problem is the form never fires the event until a field in a record get the focus. If you click on a field in the form as you scroll thru the records, you will see your labels do what they are supposed to. I'm not sure there is a work around for that.

Paul
 
Hi there

maybe when you load up the form you could set the focus to on of the controls?? Or do you need to click each individual one for each label to display correctly ..

Transcend
 
You would need to click in each record for the Current event to fire and change the label. I haven't found any way around that.

Paul
 
Could you put in your code something like

For Each cntl In Me.Controls
If TypeOf cntl Is TextBox Then
cntl.setfocus
End If
Next

??

Transcend
 
In Access 97, there's no way you can do this with a label. The only things that can be different from one record to the next in a continuous forms view is the contents of the bound controls.

In Access 2000, there's a trick you can use based on Conditional Formatting. CF lets you change characteristics of a data control's font and its enabled state based on either the value of the field or the value of an arbitrary expression.

You could add a text box for each label, using the appropriate condition to change the font's foreground color to match the background color if it's not to be visible. You probably couldn't overlap the text boxes, though--the one on top would obscure the one beneath.
Rick Sprague
 
I tried that this morning and it did work. You have to use a textbox rather than a label but if you have A2000 that seems to work. Rick, I missed the fact that you could set the condition to an expression when I looked at it last night. That's worth a star just because I learned somethinng.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top