By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,489 Members | 1,954 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,489 IT Pros & Developers. It's quick & easy.

Deeper than conditional formatting... possible?

P: 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.
Nov 10 '06 #1
Share this Question
Share on Google+
11 Replies


NeoPa
Expert Mod 15k+
P: 31,186
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.
Nov 11 '06 #2

missinglinq
Expert 2.5K+
P: 3,532
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!
Nov 11 '06 #3

PEB
Expert 100+
P: 1,418
PEB
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
Nov 11 '06 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
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.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Current()
  3.  
  4.     If <conditional statement> Then
  5.         Me.lblFirstLabelName.Visible = True
  6.         Me.lblSecondLabelName.Visible = False
  7.     Else
  8.         Me.lblFirstLabelName.Visible = False
  9.         Me.lblSecondLabelName.Visible = True
  10.     End If
  11.  
  12. End Sub
  13.  
  14.  
Nov 12 '06 #5

PEB
Expert 100+
P: 1,418
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

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.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Current()
  3.  
  4.     If <conditional statement> Then
  5.         Me.lblFirstLabelName.Visible = True
  6.         Me.lblSecondLabelName.Visible = False
  7.     Else
  8.         Me.lblFirstLabelName.Visible = False
  9.         Me.lblSecondLabelName.Visible = True
  10.     End If
  11.  
  12. End Sub
  13.  
  14.  
Nov 12 '06 #6

P: 3
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.
Nov 13 '06 #7

PEB
Expert 100+
P: 1,418
PEB
Yeap sure with this code:

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! ;)
Nov 18 '06 #8

MMcCarthy
Expert Mod 10K+
P: 14,534
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.
Nov 18 '06 #9

PEB
Expert 100+
P: 1,418
PEB
10x Mary :)
Nov 18 '06 #10

P: 3
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.
Nov 20 '06 #11

MMcCarthy
Expert Mod 10K+
P: 14,534
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

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.
Nov 20 '06 #12

Post your reply

Sign in to post your reply or Sign up for a free account.