Adding Spaces

D

DS

How do you add a space in front of a word in a field based on the
content of another field?

IIf([Item Type]="Mod",&" "&[Item Name], [Item Name])

Is this right? Or terribly wrong?

Thanks
DS
 
J

John Vinson

How do you add a space in front of a word in a field based on the
content of another field?

IIf([Item Type]="Mod",&" "&[Item Name], [Item Name])

Is this right? Or terribly wrong?

Thanks
DS

You've got an extra ampersand: Try

IIf([Item Type] = "Mod", " " & [Item Name], [Item Name])

or, perhaps a bit more efficiently, just use the IIF to generate the
blank:

IIf([Item Type] = "Mod", " ", "") & [Item Name]

John W. Vinson[MVP]
 
D

DS

John said:
How do you add a space in front of a word in a field based on the
content of another field?

IIf([Item Type]="Mod",&" "&[Item Name], [Item Name])

Is this right? Or terribly wrong?

Thanks
DS


You've got an extra ampersand: Try

IIf([Item Type] = "Mod", " " & [Item Name], [Item Name])

or, perhaps a bit more efficiently, just use the IIF to generate the
blank:

IIf([Item Type] = "Mod", " ", "") & [Item Name]

John W. Vinson[MVP]
Thaks John, I triedputting it on the Format property of the field [Item
Name] but it does weird things, I'm precedding it with an equal sign is
this right? Or should it be stuck elsewhere?
Thanks
DS
 
J

John Vinson

Thaks John, I triedputting it on the Format property of the field [Item
Name] but it does weird things, I'm precedding it with an equal sign is
this right? Or should it be stuck elsewhere?

Well, the Format property is certainly NOT the right place: valid
values in Format are... well, format strings, not the values of
fields.

Step back a bit. What are you trying to accomplish? Where? On a Form,
a Report, in a query, or what?

John W. Vinson[MVP]
 
D

DS

John said:
Thaks John, I triedputting it on the Format property of the field [Item
Name] but it does weird things, I'm precedding it with an equal sign is
this right? Or should it be stuck elsewhere?


Well, the Format property is certainly NOT the right place: valid
values in Format are... well, format strings, not the values of
fields.

Step back a bit. What are you trying to accomplish? Where? On a Form,
a Report, in a query, or what?

John W. Vinson[MVP]
Thanks John,
I have a field on a form. Whenever another field [Item Type]="Mod" I
want the [Item Name] field to have an extra 4 spaces in front of it.
Whenever the [Item Type] field = "Main" I want the [Item Name] field
just to be the way it is. I'm trying to indent the [Item Name] field
only when the [Item Type] field = "Mod".
Thank you onc again John....I'm going nuts trying to figure this out.
DS
 
J

John Vinson

I have a field on a form. Whenever another field [Item Type]="Mod" I
want the [Item Name] field to have an extra 4 spaces in front of it.
Whenever the [Item Type] field = "Main" I want the [Item Name] field
just to be the way it is. I'm trying to indent the [Item Name] field
only when the [Item Type] field = "Mod".
Thank you onc again John....I'm going nuts trying to figure this out.
DS

Do you want this Item Name field to be editable? If so it's going to
be a lot tougher!

If not, be sure that the name of the Item Name textbox is something
OTHER THAN "Item Name" - Access will get confused. Try setting it to
txtItemName for example. Set its Control Source property to

=IIF([Item Type] = "Mod", " ", "") & [Item Name])

This will *display* the name as you wish, but since it's a calculated
expression rather than a field value it won't be editable.


John W. Vinson[MVP]
 
D

DS

John said:
I have a field on a form. Whenever another field [Item Type]="Mod" I
want the [Item Name] field to have an extra 4 spaces in front of it.
Whenever the [Item Type] field = "Main" I want the [Item Name] field
just to be the way it is. I'm trying to indent the [Item Name] field
only when the [Item Type] field = "Mod".
Thank you onc again John....I'm going nuts trying to figure this out.
DS


Do you want this Item Name field to be editable? If so it's going to
be a lot tougher!

If not, be sure that the name of the Item Name textbox is something
OTHER THAN "Item Name" - Access will get confused. Try setting it to
txtItemName for example. Set its Control Source property to

=IIF([Item Type] = "Mod", " ", "") & [Item Name])

This will *display* the name as you wish, but since it's a calculated
expression rather than a field value it won't be editable.


John W. Vinson[MVP]
John,
That works GREAT!!!!! Your a Genius!!
Once again Thank You!
Sincerely,
DS
 
D

DS

DS said:
John said:
I have a field on a form. Whenever another field [Item Type]="Mod" I
want the [Item Name] field to have an extra 4 spaces in front of it.
Whenever the [Item Type] field = "Main" I want the [Item Name] field
just to be the way it is. I'm trying to indent the [Item Name] field
only when the [Item Type] field = "Mod".
Thank you onc again John....I'm going nuts trying to figure this out.
DS



Do you want this Item Name field to be editable? If so it's going to
be a lot tougher!

If not, be sure that the name of the Item Name textbox is something
OTHER THAN "Item Name" - Access will get confused. Try setting it to
txtItemName for example. Set its Control Source property to

=IIF([Item Type] = "Mod", " ", "") & [Item Name])

This will *display* the name as you wish, but since it's a calculated
expression rather than a field value it won't be editable.


John W. Vinson[MVP]

John,
That works GREAT!!!!! Your a Genius!!
Once again Thank You!
Sincerely,
DS
Hi John,
Everythings working great except one quick question. I have the fields
set to "Not Enabled" and "Locked" which works for the [Item Name] but
when the spaces are stuck in it the cursor is allowed to enter the
textbox. You can't change anything but its in there none the less. How
can I stop that from happening?
Thanks
DS
 
D

DS

DS said:
DS said:
John said:
I have a field on a form. Whenever another field [Item Type]="Mod"
I want the [Item Name] field to have an extra 4 spaces in front of
it. Whenever the [Item Type] field = "Main" I want the [Item Name]
field just to be the way it is. I'm trying to indent the [Item
Name] field only when the [Item Type] field = "Mod".
Thank you onc again John....I'm going nuts trying to figure this out.
DS




Do you want this Item Name field to be editable? If so it's going to
be a lot tougher!

If not, be sure that the name of the Item Name textbox is something
OTHER THAN "Item Name" - Access will get confused. Try setting it to
txtItemName for example. Set its Control Source property to

=IIF([Item Type] = "Mod", " ", "") & [Item Name])

This will *display* the name as you wish, but since it's a calculated
expression rather than a field value it won't be editable.


John W. Vinson[MVP]


John,
That works GREAT!!!!! Your a Genius!!
Once again Thank You!
Sincerely,
DS

Hi John,
Everythings working great except one quick question. I have the fields
set to "Not Enabled" and "Locked" which works for the [Item Name] but
when the spaces are stuck in it the cursor is allowed to enter the
textbox. You can't change anything but its in there none the less. How
can I stop that from happening?
Thanks
DS
Found the Problem, I was using conditional formatting to make the field
red if [ItemType]="Mods", whenever I took that off the field became
locked again. Can I do that from instead? How would I word it?
Thanks
DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top