473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Access 2002 Conditional Caption

I have a form that returns 100 items. All of the items have have a
different value in their Category field.

EXAMPLE:
----------------
A
B
C

How can I change the value of the caption in the field label on the
form based on the category? I attempted a series of Case statements
but it didn't seem to work when values of mixed categories were
returned.

Select Case PriceCat
Case "A"
MsgBox ([tblProduct.PriceTyp])
Me![frmSubSearch].Form.prdPrice1Gl.ControlSource =
"PriceTypeA"
Me![frmSubSearch].Form.prdPrice5Gl.ControlSource =
"PriceTypeB"
Me![frmSubSearch].Form.prdPrice5GlCF.ControlSource =
"PriceTypeC"
Me![frmSubSearch].Form.lblItemSubPrice1.Caption = "A"
Me![frmSubSearch].Form.lblItemSubPrice5.Caption = "B"
Me![frmSubSearch].Form.lblItemSubPrice5CF.Caption = "C"
Case Else
Me![frmSubSearch].Form.prdPrice1Gl.ControlSource = "1"
Me![frmSubSearch].Form.prdPrice5Gl.ControlSource = "2"
Me![frmSubSearch].Form.prdPrice5GlCF.ControlSource = "3"
Me![frmSubSearch].Form.lblItemSubPrice1.Caption = "1"
Me![frmSubSearch].Form.lblItemSubPrice5.Caption = "2"
Me![frmSubSearch].Form.lblItemSubPrice5CF.Caption = "3"
End Select
Jan 16 '08 #1
7 2105
What you could try is this,

in your form's current event, you could implement a simple 'If'
statement

i.e.

if pricecat = "A" Then
yourlabel.caption = "The category is A"
elseif pricecat = "B" Then
yourlabel.caption = "The category is B"
elseif pricecat = "C" Then
yourlabel.caption = "The category is C"
else
yourlabel.caption = "Category not A,B, or C"
End if

I think that should work.
Jan 16 '08 #2
Mixed Catagories? It sounds like your main form is set to 'Continuous
View'. I expect that you would only have one catagory per Record.
Your code will only work in you Current Record. So the labels should
change when you go to the next record.

Dominic

<dk****@gmail.comwrote in message
news:02**********************************@c23g2000 hsa.googlegroups.com...
>I have a form that returns 100 items. All of the items have have a
different value in their Category field.

EXAMPLE:
----------------
A
B
C

How can I change the value of the caption in the field label on the
form based on the category? I attempted a series of Case statements
but it didn't seem to work when values of mixed categories were
returned.

Select Case PriceCat
Case "A"
MsgBox ([tblProduct.PriceTyp])
Me![frmSubSearch].Form.prdPrice1Gl.ControlSource =
"PriceTypeA"
Me![frmSubSearch].Form.prdPrice5Gl.ControlSource =
"PriceTypeB"
Me![frmSubSearch].Form.prdPrice5GlCF.ControlSource =
"PriceTypeC"
Me![frmSubSearch].Form.lblItemSubPrice1.Caption = "A"
Me![frmSubSearch].Form.lblItemSubPrice5.Caption = "B"
Me![frmSubSearch].Form.lblItemSubPrice5CF.Caption = "C"
Case Else
Me![frmSubSearch].Form.prdPrice1Gl.ControlSource = "1"
Me![frmSubSearch].Form.prdPrice5Gl.ControlSource = "2"
Me![frmSubSearch].Form.prdPrice5GlCF.ControlSource = "3"
Me![frmSubSearch].Form.lblItemSubPrice1.Caption = "1"
Me![frmSubSearch].Form.lblItemSubPrice5.Caption = "2"
Me![frmSubSearch].Form.lblItemSubPrice5CF.Caption = "3"
End Select

Jan 16 '08 #3
On Jan 16, 2:02 pm, "Dominic Vella" <dominic.ve...@optusnet.com.au>
wrote:
Mixed Catagories? It sounds like your main form is set to 'Continuous
View'. I expect that you would only have one catagory per Record.
Your code will only work in you Current Record. So the labels should
change when you go to the next record.

Dominic

<dko...@gmail.comwrote in message

news:02**********************************@c23g2000 hsa.googlegroups.com...
I have a form that returns 100 items. All of the items have have a
different value in their Category field.
EXAMPLE:
----------------
A
B
C
How can I change the value of the caption in the field label on the
form based on the category? I attempted a series of Case statements
but it didn't seem to work when values of mixed categories were
returned.
Select Case PriceCat
Case "A"
MsgBox ([tblProduct.PriceTyp])
Me![frmSubSearch].Form.prdPrice1Gl.ControlSource =
"PriceTypeA"
Me![frmSubSearch].Form.prdPrice5Gl.ControlSource =
"PriceTypeB"
Me![frmSubSearch].Form.prdPrice5GlCF.ControlSource =
"PriceTypeC"
Me![frmSubSearch].Form.lblItemSubPrice1.Caption = "A"
Me![frmSubSearch].Form.lblItemSubPrice5.Caption = "B"
Me![frmSubSearch].Form.lblItemSubPrice5CF.Caption = "C"
Case Else
Me![frmSubSearch].Form.prdPrice1Gl.ControlSource = "1"
Me![frmSubSearch].Form.prdPrice5Gl.ControlSource = "2"
Me![frmSubSearch].Form.prdPrice5GlCF.ControlSource = "3"
Me![frmSubSearch].Form.lblItemSubPrice1.Caption = "1"
Me![frmSubSearch].Form.lblItemSubPrice5.Caption = "2"
Me![frmSubSearch].Form.lblItemSubPrice5CF.Caption = "3"
End Select
The form is set to continuous because I am returning more than one
record. I am returning the records for view only.
Jan 17 '08 #4
I'd consider using a list box with the results, and let the user select the
result they would like more detail from, then you can use the 'Single View'.

In any case, make sure your code is placed in your Form_Current event.

Dominic

<dk****@gmail.comwrote in message
news:01**********************************@v46g2000 hsv.googlegroups.com...
On Jan 16, 2:02 pm, "Dominic Vella" <dominic.ve...@optusnet.com.au>
wrote:
>Mixed Catagories? It sounds like your main form is set to 'Continuous
View'. I expect that you would only have one catagory per Record.
Your code will only work in you Current Record. So the labels should
change when you go to the next record.

Dominic

<dko...@gmail.comwrote in message

news:02**********************************@c23g200 0hsa.googlegroups.com...
>I have a form that returns 100 items. All of the items have have a
different value in their Category field.
EXAMPLE:
----------------
A
B
C
How can I change the value of the caption in the field label on the
form based on the category? I attempted a series of Case statements
but it didn't seem to work when values of mixed categories were
returned.
Select Case PriceCat
Case "A"
MsgBox ([tblProduct.PriceTyp])
Me![frmSubSearch].Form.prdPrice1Gl.ControlSource =
"PriceTypeA"
Me![frmSubSearch].Form.prdPrice5Gl.ControlSource =
"PriceTypeB"
Me![frmSubSearch].Form.prdPrice5GlCF.ControlSource =
"PriceTypeC"
Me![frmSubSearch].Form.lblItemSubPrice1.Caption = "A"
Me![frmSubSearch].Form.lblItemSubPrice5.Caption = "B"
Me![frmSubSearch].Form.lblItemSubPrice5CF.Caption = "C"
Case Else
Me![frmSubSearch].Form.prdPrice1Gl.ControlSource = "1"
Me![frmSubSearch].Form.prdPrice5Gl.ControlSource = "2"
Me![frmSubSearch].Form.prdPrice5GlCF.ControlSource = "3"
Me![frmSubSearch].Form.lblItemSubPrice1.Caption = "1"
Me![frmSubSearch].Form.lblItemSubPrice5.Caption = "2"
Me![frmSubSearch].Form.lblItemSubPrice5CF.Caption = "3"
End Select

The form is set to continuous because I am returning more than one
record. I am returning the records for view only.

Jan 17 '08 #5
On Jan 16, 7:19 pm, "Dominic Vella" <dominic.ve...@optusnet.com.au>
wrote:
I'd consider using a list box with the results, and let the user select the
result they would like more detail from, then you can use the 'Single View'.

In any case, make sure your code is placed in your Form_Current event.

Dominic

<dko...@gmail.comwrote in message

news:01**********************************@v46g2000 hsv.googlegroups.com...
On Jan 16, 2:02 pm, "Dominic Vella" <dominic.ve...@optusnet.com.au>
wrote:
Mixed Catagories? It sounds like your main form is set to 'Continuous
View'. I expect that you would only have one catagory per Record.
Your code will only work in you Current Record. So the labels should
change when you go to the next record.
Dominic
<dko...@gmail.comwrote in message
>news:02**********************************@c23g200 0hsa.googlegroups.com...
I have a form that returns 100 items. All of the items have have a
different value in their Category field.
EXAMPLE:
----------------
A
B
C
How can I change the value of the caption in the field label on the
form based on the category? I attempted a series of Case statements
but it didn't seem to work when values of mixed categories were
returned.
Select Case PriceCat
Case "A"
MsgBox ([tblProduct.PriceTyp])
Me![frmSubSearch].Form.prdPrice1Gl.ControlSource =
"PriceTypeA"
Me![frmSubSearch].Form.prdPrice5Gl.ControlSource =
"PriceTypeB"
Me![frmSubSearch].Form.prdPrice5GlCF.ControlSource =
"PriceTypeC"
Me![frmSubSearch].Form.lblItemSubPrice1.Caption = "A"
Me![frmSubSearch].Form.lblItemSubPrice5.Caption = "B"
Me![frmSubSearch].Form.lblItemSubPrice5CF.Caption = "C"
Case Else
Me![frmSubSearch].Form.prdPrice1Gl.ControlSource = "1"
Me![frmSubSearch].Form.prdPrice5Gl.ControlSource = "2"
Me![frmSubSearch].Form.prdPrice5GlCF.ControlSource = "3"
Me![frmSubSearch].Form.lblItemSubPrice1.Caption = "1"
Me![frmSubSearch].Form.lblItemSubPrice5.Caption = "2"
Me![frmSubSearch].Form.lblItemSubPrice5CF.Caption = "3"
End Select
The form is set to continuous because I am returning more than one
record. I am returning the records for view only.
Listbox won't work...that is how I had the form initially...but the
user group would like to see it all at once...
Jan 17 '08 #6
On Jan 16, 1:56 pm, Brian <Brian.Kib...@gmail.comwrote:
What you could try is this,

in your form's current event, you could implement a simple 'If'
statement

i.e.

if pricecat = "A" Then
yourlabel.caption = "The category is A"
elseif pricecat = "B" Then
yourlabel.caption = "The category is B"
elseif pricecat = "C" Then
yourlabel.caption = "The category is C"
else
yourlabel.caption = "Category not A,B, or C"
End if

I think that should work.
Didn't seem to work. All the category labels were = "Category not
A,B, or C". All the items in the return were from category A, B, C
with the exception of the first item in the resultset that was not.
When I remove that item, the first item in the result set is from
Category B, and all the labels are then = "Category B".
Jan 18 '08 #7
On Thu, 17 Jan 2008 08:27:06 -0800 (PST), "dk****@gmail.com" <dk****@gmail.com>
wrote:
>On Jan 16, 7:19 pm, "Dominic Vella" <dominic.ve...@optusnet.com.au>
wrote:
>I'd consider using a list box with the results, and let the user select the
result they would like more detail from, then you can use the 'Single View'.

In any case, make sure your code is placed in your Form_Current event.

Dominic

<dko...@gmail.comwrote in message

news:01**********************************@v46g200 0hsv.googlegroups.com...
On Jan 16, 2:02 pm, "Dominic Vella" <dominic.ve...@optusnet.com.au>
wrote:
Mixed Catagories? It sounds like your main form is set to 'Continuous
View'. I expect that you would only have one catagory per Record.
Your code will only work in you Current Record. So the labels should
change when you go to the next record.
>Dominic
><dko...@gmail.comwrote in message
>>news:02**********************************@c23g20 00hsa.googlegroups.com...
>I have a form that returns 100 items. All of the items have have a
different value in their Category field.
EXAMPLE:
----------------
A
B
C
How can I change the value of the caption in the field label on the
form based on the category? I attempted a series of Case statements
but it didn't seem to work when values of mixed categories were
returned.
Select Case PriceCat
Case "A"
MsgBox ([tblProduct.PriceTyp])
Me![frmSubSearch].Form.prdPrice1Gl.ControlSource =
"PriceTypeA"
Me![frmSubSearch].Form.prdPrice5Gl.ControlSource =
"PriceTypeB"
Me![frmSubSearch].Form.prdPrice5GlCF.ControlSource =
"PriceTypeC"
Me![frmSubSearch].Form.lblItemSubPrice1.Caption = "A"
Me![frmSubSearch].Form.lblItemSubPrice5.Caption = "B"
Me![frmSubSearch].Form.lblItemSubPrice5CF.Caption = "C"
Case Else
Me![frmSubSearch].Form.prdPrice1Gl.ControlSource = "1"
Me![frmSubSearch].Form.prdPrice5Gl.ControlSource = "2"
Me![frmSubSearch].Form.prdPrice5GlCF.ControlSource = "3"
Me![frmSubSearch].Form.lblItemSubPrice1.Caption = "1"
Me![frmSubSearch].Form.lblItemSubPrice5.Caption = "2"
Me![frmSubSearch].Form.lblItemSubPrice5CF.Caption = "3"
End Select
The form is set to continuous because I am returning more than one
record. I am returning the records for view only.

Listbox won't work...that is how I had the form initially...but the
user group would like to see it all at once...
Replace the label with a text box (disabled and locked).
Either create a calculated field in the recordsource of the form that returns
the correct caption for the record and bind the textbox to this field.

OR

Create a function that returns the required caption based on parameters past to
it and bind the textbox to this function. This will be significantly slower than
the first option and may result in a staggered screen update.

If you use a label whatever caption you set will apply to every record in the
continuous form. Using a textbox allows each record to be evaluated and
displayed individually.
Wayne Gillespie
Gosford NSW Australia
Jan 18 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Richard | last post by:
Hi, I have a form that take some time to load due to many comboboxes and at least 8 subforms. When I filter or sort the main form I get an error message and then Access shuts down. They ask if...
4
by: Wayne Aprato | last post by:
I have a simple database which was originally written in Access 97. When converted to Access 2000 file format it ran flawlessly in Access 2002. I've just tried to run it in Access 2003 and I am...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
1
by: Arif | last post by:
I have a bizarre problem. I am using a code module to update the Caption property of the buttons of a custom toolbar. Though the code module works fine, the new caption does not immediately show on...
5
by: Andrew Chanter | last post by:
Does anyone know a way you can use conditional formatting to create a banded style view as is commonly seen on the internet. (In othe words the first record appears on a gray background, the 2nd...
1
by: RIP662 | last post by:
Okay all you GURUS out there... here's the skinny... I need a way to prevent the Me.Dirty event to trigger after a FORM_OPEN event. What I have is a field that is dependent on another field that...
42
by: lauren quantrell | last post by:
So many postings on not to use the treeview control, but nothing recently. Is it safe to swim there yet with Access 2000-Access 2003?
23
by: Wayne Wengert | last post by:
In a Datagrid I have a field (<td>) in which I want to display a link if a database field is still Null but I want to display a blank (&nbsp;) if that DB field has a value. If I try to put the...
0
by: dkohel | last post by:
I have a form that returns 100 items. All of the items have have a different value in their Category field. EXAMPLE: ---------------- A B C How can I change the value of the caption in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.