Deeper than conditional formatting... possible? | Newbie | | Join Date: Nov 2006
Posts: 3
| | |
Okay, here goes.
Continuous forms... possibly the best feature of access. The only downside is this: the only way to have a conditional evaluation run on each record invididually is by conditional formatting... this poses a problem because it is extremely limited (no wildcards, cannot access controls other than the one the formatting is on, cannot perform evaluations other than the ones give... greater than, less than etc).
Is there a way, even if it involves cycling through each record via a for loop, to evaluate or even reference items on invididual lines...
Is there an array somewhere with each member of the 'master' control in it? If i say "chkbox.checked = true" then obviously ALL of the checkboxes will check (for as many records as you have showing on your continuous form)... this is not what i'm looking for. Is there a way to programmatically ONLY check one of them (obviously clicking on it would work, but given only the index number of that record, ie: checkbox[4].checked = true)?
Here is an example that, if solved, I could adapt easily to do what I want:
You have a continuous form, some text boxes with their datasources set etc... now in design mode (which you only see your 'template' record), you have a lable, not linked to anything... just with static text in it (lets call it lblTest) and set its caption to 'Test'. Now there are 20 records... I have 20 'rows' on this form and each of them has a label that says "Test" and a bunch of varying information in the other linked text boxes...
if I simply code ... lblTest.caption = "changeme" ... then all 20 labels will change to that.. is there a way to change, say, only the 4th row label's caption? programatically without resorting to conditional formatting?
Hopefully this is a hurdle that can be overcome because it is extremely limiting.
|  | Administrator | | Join Date: Oct 2006 Location: London - UK
Posts: 15,730
| | | re: Deeper than conditional formatting... possible?
I'm not too sure what effect could be achieved, but try playing with the OnCurrent event.
This should enable you to format individual records, but I'm not too sure about all the rest.
Play with it and see what you can do.
|  | Moderator | | Join Date: Nov 2006 Location: Richmond, Virginia USA
Posts: 3,000
| | | re: Deeper than conditional formatting... possible?
My question is, how do you figure Continuous forms... possibly the best feature of access when it allows you to do nothing that you wish to do? Continuous forms are undoubtedly the worst feature (form-wise) for all the reasons you've enumerated!
|  | Expert | | Join Date: Aug 2006 Location: Bulgaria
Posts: 1,380
| | | re: Deeper than conditional formatting... possible?
Hi
If you want on each row have different label....
The best way is to have separate field in your database ie Label1
There you can determine what information should be like Label...
By default you introduce a value but if there is a record with a label that should be different you change the field..
In your Continious form instaed to use the Label Control use the Field Control that is locked, filled like a label...and don't has the focus... And on clicking on this field create a function that sets the focus to the respective field to be updated...
Hope this helps
|  | Administrator | | Join Date: Aug 2006 Location: Dublin, Ireland
Posts: 10,885
| | | re: Deeper than conditional formatting... possible? Quote:
Originally Posted by tg989 Okay, here goes.
Continuous forms... possibly the best feature of access. The only downside is this: the only way to have a conditional evaluation run on each record invididually is by conditional formatting... this poses a problem because it is extremely limited (no wildcards, cannot access controls other than the one the formatting is on, cannot perform evaluations other than the ones give... greater than, less than etc).
Is there a way, even if it involves cycling through each record via a for loop, to evaluate or even reference items on invididual lines...
Is there an array somewhere with each member of the 'master' control in it? If i say "chkbox.checked = true" then obviously ALL of the checkboxes will check (for as many records as you have showing on your continuous form)... this is not what i'm looking for. Is there a way to programmatically ONLY check one of them (obviously clicking on it would work, but given only the index number of that record, ie: checkbox[4].checked = true)?
Here is an example that, if solved, I could adapt easily to do what I want:
You have a continuous form, some text boxes with their datasources set etc... now in design mode (which you only see your 'template' record), you have a lable, not linked to anything... just with static text in it (lets call it lblTest) and set its caption to 'Test'. Now there are 20 records... I have 20 'rows' on this form and each of them has a label that says "Test" and a bunch of varying information in the other linked text boxes...
if I simply code ... lblTest.caption = "changeme" ... then all 20 labels will change to that.. is there a way to change, say, only the 4th row label's caption? programatically without resorting to conditional formatting?
Hopefully this is a hurdle that can be overcome because it is extremely limiting. If you just want to toggle between two label values then I would suggest creating two labels and making one of them invisible. Then put something like this in the Form_Current event. -
-
Private Sub Form_Current()
-
-
If <conditional statement> Then
-
Me.lblFirstLabelName.Visible = True
-
Me.lblSecondLabelName.Visible = False
-
Else
-
Me.lblFirstLabelName.Visible = False
-
Me.lblSecondLabelName.Visible = True
-
End If
-
-
End Sub
-
-
|  | Expert | | Join Date: Aug 2006 Location: Bulgaria
Posts: 1,380
| | | re: Deeper than conditional formatting... possible?
Or simply changing the label Caption like this:
If testvalue=testresult then
Me.lblFirstLabelName.Caption = "Les banans viennent de:"
Else
Me.lblFirstLabelName.Caption = "Les abricots sont:"
end if Quote:
Originally Posted by mmccarthy If you just want to toggle between two label values then I would suggest creating two labels and making one of them invisible. Then put something like this in the Form_Current event. -
-
Private Sub Form_Current()
-
-
If <conditional statement> Then
-
Me.lblFirstLabelName.Visible = True
-
Me.lblSecondLabelName.Visible = False
-
Else
-
Me.lblFirstLabelName.Visible = False
-
Me.lblSecondLabelName.Visible = True
-
End If
-
-
End Sub
-
-
| | Newbie | | Join Date: Nov 2006
Posts: 3
| | | re: Deeper than conditional formatting... possible? Quote:
Originally Posted by PEB Or simply changing the label Caption like this:
If testvalue=testresult then
Me.lblFirstLabelName.Caption = "Les banans viennent de:"
Else
Me.lblFirstLabelName.Caption = "Les abricots sont:"
end if
I think that the form_current has some potential, I'll try it and see what happens!
btw the reason I said that continuous forms was possibly the best feature is because it would take you several weeks to make a datagrid in vb.net that gives you the same effect. Everything else that access has going for it, some other language/ide can do better.
PEB - your suggestion only works when you have 1 label... if you have several, ie: on a continuous form, you would find that it changes all the labels captions depending on that 1 if statement.
|  | Expert | | Join Date: Aug 2006 Location: Bulgaria
Posts: 1,380
| | | re: Deeper than conditional formatting... possible?
Yeap sure with this code: Quote:
Originally Posted by PEB
Or simply changing the label Caption like this:
If testvalue=testresult then
Me.lblFirstLabelName.Caption = "Les banans viennent de:"
Else
Me.lblFirstLabelName.Caption = "Les abricots sont:"
end if
But if you catch my previous idea... To create a field in your table, named label...
And programatically change it's content... The field used for label should change and only on the respective record!
I give garantees!
PLS belive me! ;)
|  | Administrator | | Join Date: Aug 2006 Location: Dublin, Ireland
Posts: 10,885
| | | re: Deeper than conditional formatting... possible? Quote:
Originally Posted by PEB Yeap sure with this code:
But if you catch my previous idea... To create a field in your table, named label...
And programatically change it's content... The field used for label should change and only on the respective record!
I give garantees!
PLS belive me! ;) That's a great idea PEB.
|  | Expert | | Join Date: Aug 2006 Location: Bulgaria
Posts: 1,380
| | | re: Deeper than conditional formatting... possible?
10x Mary :)
| | Newbie | | Join Date: Nov 2006
Posts: 3
| | | re: Deeper than conditional formatting... possible?
Thats cheating :)
besides, I was trying to avoid bloating my tables with excessive fields that can be calculated on the fly.
I have however found the solution. basically you set the datasource of a text box to
"=IIf( [someotherfield] = "whatever", 'code executed if true', 'code executed if false')
you can get pretty creative with what goes in there and as a result, change the values of fields that are not related...
this has alleviated the original problem with very acceptable results and if anybody else is up against this same wall, i'd be glad to post some more thorough source code and explainations.
|  | Administrator | | Join Date: Aug 2006 Location: Dublin, Ireland
Posts: 10,885
| | | re: Deeper than conditional formatting... possible?
When you find solutions like this, particularly to conditional formatting it's always nice to post the full code so that anyone searching the question in the future can see the full solution.
It's a very nice idea.
Mary Quote:
Originally Posted by tg989 Thats cheating :)
besides, I was trying to avoid bloating my tables with excessive fields that can be calculated on the fly.
I have however found the solution. basically you set the datasource of a text box to
"=IIf( [someotherfield] = "whatever", 'code executed if true', 'code executed if false')
you can get pretty creative with what goes in there and as a result, change the values of fields that are not related...
this has alleviated the original problem with very acceptable results and if anybody else is up against this same wall, i'd be glad to post some more thorough source code and explainations. |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,449 network members.
|