Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

comparing part of a text field in code 3

Status
Not open for further replies.

MHadden

Programmer
May 13, 2001
105
Greetings All:
I have need to check a field to see if it contains the string "GEN" if it only contains this string the following code works great, however, almost all of the textboxes contain a 10 letter word & these three letters show up in some of them.
I have tried many different variations with no success. I'm posting now in hopes that someone can help.

Code:
Private Sub Form_Current()
  If [Product_Number].Seltext = "*GEN*" then
     frmProductsAvailable.IsVisible true
     else
     frmProductsAvailable.IsVisible False
     End If
  End Sub

Any help is appreciated!
- Michael

MichaelHadden@yahoo.com
If you give someone a fish, you have given them a meal. If you teach someone to fish, you have given them MANY meals!
 
Hi,
Code:
  If [Product_Number].Seltext [b]Like[/b] "*GEN*" then

Skip,
[sub]
[glasses] [red]Be advised:[/red] When you ignite a firecracker in a bowl of vanilla, chocolate & strawberry ice cream, you get...
Neopolitan Blownapart! [tongue][/sub]

 
You are aware that the .seltext property of Access form controls only contain the selected text? To compare the whole text of the control, use the .Value property of the control (or don't specify any property, as the .value property is the default property).

Also - I'm lead to believe that the IsVisible property of controls, is only used/available in the on print event of reports? Should you get into problems, try:

[tt]frmProductsAvailable.Visible = true[/tt]

Roy-Vidar
 
Thanks to both of you!!

Skip's code did work, but only after I changed "IsVisible" to "Visible", like Roy-Vidar said to do.

I haven't noticed a problem using SelText, so I didn't change it to Value, but I'm keeping an eye on it. Previously, when I tried it without specifying a property, it didn't work.

Either way, you both deserve a STAR & I thank you very much!

- Michael

MichaelHadden@yahoo.com
If you give someone a fish, you have given them a meal. If you teach someone to fish, you have given them MANY meals!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top