IIF Immediate If Statement for formating woes

  • Thread starter Thread starter bobdydd
  • Start date Start date
B

bobdydd

Hi

I am trying to coditionally format a field based on the statement
below

What I need is to detect the presence of the word Ebay in the field
txtSubject
and format accordingly

IIf([txtSubject]="Like "*" & "Ebay" & "*"",True,False) None

Grateful for any help
 
bobdydd used his keyboard to write :
Hi

I am trying to coditionally format a field based on the statement
below

What I need is to detect the presence of the word Ebay in the field
txtSubject
and format accordingly

IIf([txtSubject]="Like "*" & "Ebay" & "*"",True,False) None

Grateful for any help

IIf(InStr(Me.[txtSubject], "Ebay") > 0,True,False)
 
where are you wanting to use this expression? and what is the purpose of
"None" tacked on at the end? if you're using the Conditional Formatting
option from the Format menu in form Design view, then John's code posted
elsewhere in this thread should work, if you remove the Me reference -
again, not taking into account that ambiguous "None".

if you're trying to "toggle" a property setting between True and False in
VBA, then try

Me!txtSubject.SomeProperty = (InStr(Me![txtSubject], "Ebay") > 0)

replace SomeProperty with the name of the property, of course. and again,
disregarding the "None" in your original post.

hth
 
Hi Tina

John's code worked fine for my conditional formatting expression, you
code has taken me to a more ambitious
level.

I have a continuous form with 2 Cmd Buttons (CmdSHOP and CmdFIXED)

what I would really like is to make:
CmdFIXED.visible = False & CmdSHOP.visible = True
if "eBay" is present in the txtSubjectField

I have tried putting this on the current event
IIf Me(CmdSHOP.Visible = False) = (InStr(Me![txtSubject], "eBay Item
Sold:") > 0)

But no Joy yet

Thanks for your help
 
Thanks for the reply Salad

I am placing this code in my Continuous Forms Current Event
Me.CmdSHOP.Visible = IIf(InStr(Me![txtSubject], "You've sold your eBay
item:") > 0, True, False)
Me.CmdFIXED.Visible = IIf(InStr(Me![txtSubject], "eBay Item Sold:") >
0, True, False)

And I would have thought it would differentiate the records that say
"You've sold your eBay item:"
from the ones that say "eBay Item Sold:

BTW this is used to differentiate beween eBay sales from eBay Shops
and those from ordinary Listings

Thanks for the help
 
you're making this more complex than it has to be. forget the IIf()
function. and it would help if you would stick with one goal for a couple
posts. each time you respond, you're changing what you say you want to do -
so it's hard for anyone to give you a solution that works.

i'll go with the code you included in this last post:
Me.CmdSHOP.Visible = IIf(InStr(Me![txtSubject], "You've sold your eBay
item:") > 0, True, False)
Me.CmdFIXED.Visible = IIf(InStr(Me![txtSubject], "eBay Item Sold:") >
0, True, False)

if you're running the code in a form set to ContinuousForms view, the change
you make to the *Current* record will be reflected in *all* the records that
show on-screen. the properties will reset appropriately as you move from
record to record - but each time the change will show on all the records
visible on-screen, not just the current record. if you don't want that
effect, you'll have to use the ConditionalFormatting option, and set the
controls to be enabled/disabled, rather than visible/not visible.

but if you don't care about the blanket effect on non-Current records, go
ahead and use VBA code, just keep it simple, as

Me!CmdSHOP.Visible = (InStr(Me!txtSubject, _
"You've sold your eBay item:") > 0)
Me!CmdFIXED.Visible = (InStr(Me!txtSubject, "eBay Item Sold:") > 0)

here's how it works: the RIGHT SIDE of the equation is a complete
expression in itself, which includes a comparison operator (>). the system
evaluates the expression and returns True or False. that return value is
used to set the value of the property named on the LEFT SIDE of the
equation. it's really that simple.

hth


put_upon said:
Thanks for the reply Salad

I am placing this code in my Continuous Forms Current Event
Me.CmdSHOP.Visible = IIf(InStr(Me![txtSubject], "You've sold your eBay
item:") > 0, True, False)
Me.CmdFIXED.Visible = IIf(InStr(Me![txtSubject], "eBay Item Sold:") >
0, True, False)

And I would have thought it would differentiate the records that say
"You've sold your eBay item:"
from the ones that say "eBay Item Sold:

BTW this is used to differentiate beween eBay sales from eBay Shops
and those from ordinary Listings

Thanks for the help
 
Thanks Tina

I was barking up the wrong tree

I was under the impression that by using the IIF Statement I could
turn on/off the
SHOP/FIXED Buttons in a simalar way that one can do with Condional
Formatting
on Text Boxes

I am able to format a text box in Condional Formatting, but it's not
possible to
enable/disable or hide/show a command button

What I'm currently doing is having a text box that turns red or green
to indicate whether
press CmdSHOP or CmdFIXED. But it's not the ideal solution

Thanks for your helpful insights
 
you're welcome. but take a second look at ConditionalFormatting. there is an
Enable/Disable option available in A2000 and A2003; i don't know about
A2007.

hth
 
Hi Tina

I have gone back to Conditional Formatting as you suggested and have
created 2 raised text boxes that look like command button that enable/
disable correctly. Maybe the next version of Access should include
formatting on Command buttons too, and have a visible/invisible
alternative.

Thanks for your help

Regards
 

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

Back
Top