Hi could someone show me the correct way of writing this code:
If Me.TextBox1.Text = "Apples" or "pears" Then
Unload Me
UserForm4.Show
End If
thanks
GK
Hi could someone show me the correct way of writing this code:
If Me.TextBox1.Text = "Apples" or "pears" Then
Unload Me
UserForm4.Show
End If
thanks
GK
Hi
Try this one:
If Ucase(Me.TextBox1.Text) = "APPLES" Or _
Ucase(Me.TextBox1.Text) = "PEARS" Then
Unload Me
UserForm4.Show
End If
The use of Ucase() means, that the user can
enter any combination of upper- and/or lower case
in the text box.
--
Best Regards
Leo Heuser
Followup to newsgroup only please.
"gregork" <[email protected]> skrev i en meddelelse
news:[email protected]...
> Hi could someone show me the correct way of writing this code:
>
> If Me.TextBox1.Text = "Apples" or "pears" Then
> Unload Me
> UserForm4.Show
> End If
>
> thanks
> GK
>
>
Thanks for the reply. Can't get it to work though. Not sure why?
cheers
GK
"Leo Heuser" <[email protected]> wrote in message
news:[email protected]...
> Hi
>
> Try this one:
>
> If Ucase(Me.TextBox1.Text) = "APPLES" Or _
> Ucase(Me.TextBox1.Text) = "PEARS" Then
> Unload Me
> UserForm4.Show
> End If
>
> The use of Ucase() means, that the user can
> enter any combination of upper- and/or lower case
> in the text box.
>
> --
> Best Regards
> Leo Heuser
>
> Followup to newsgroup only please.
>
> "gregork" <[email protected]> skrev i en meddelelse
> news:[email protected]...
> > Hi could someone show me the correct way of writing this code:
> >
> > If Me.TextBox1.Text = "Apples" or "pears" Then
> > Unload Me
> > UserForm4.Show
> > End If
> >
> > thanks
> > GK
> >
> >
>
>
Hello Gregork,
Try this:
With Me.TextBox1
If .Text = "Apples" or .Text = "pears" Then
Me.Hide
UserForm4.Show
End If
End With
Unload Me
_________________________________________________________________
If you want your code be insensitive to case, you should use Leo's suggestion. The main problem is you were Unloading your form. This removes it from memory and frees all resources associated with the form. Hiding will keep it memory but not displayed. I suspect the your form is modal. Only one form can be modal at time. So to display UserForm4, Me has to reliquish control either by being hidden or unloaded.
All the best to you,
Leith Ross
If instr(1,Me.Textbox1.Text,"apples",vbTextcompare) > 0 or _
instr(1,Me.Textbox1.Text,"pears",vbTextcompare) > 0 then
Unload Me
Userform4.Show
End if
--
Regards,
Tom Ogilvy
"Leo Heuser" <[email protected]> wrote in message
news:[email protected]...
> Hi
>
> Try this one:
>
> If Ucase(Me.TextBox1.Text) = "APPLES" Or _
> Ucase(Me.TextBox1.Text) = "PEARS" Then
> Unload Me
> UserForm4.Show
> End If
>
> The use of Ucase() means, that the user can
> enter any combination of upper- and/or lower case
> in the text box.
>
> --
> Best Regards
> Leo Heuser
>
> Followup to newsgroup only please.
>
> "gregork" <[email protected]> skrev i en meddelelse
> news:[email protected]...
> > Hi could someone show me the correct way of writing this code:
> >
> > If Me.TextBox1.Text = "Apples" or "pears" Then
> > Unload Me
> > UserForm4.Show
> > End If
> >
> > thanks
> > GK
> >
> >
>
>
Works perfectly thanks Tom
Regards
GK
"Tom Ogilvy" <[email protected]> wrote in message
news:%[email protected]...
> If instr(1,Me.Textbox1.Text,"apples",vbTextcompare) > 0 or _
> instr(1,Me.Textbox1.Text,"pears",vbTextcompare) > 0 then
> Unload Me
> Userform4.Show
> End if
>
> --
> Regards,
> Tom Ogilvy
>
>
> "Leo Heuser" <[email protected]> wrote in message
> news:[email protected]...
> > Hi
> >
> > Try this one:
> >
> > If Ucase(Me.TextBox1.Text) = "APPLES" Or _
> > Ucase(Me.TextBox1.Text) = "PEARS" Then
> > Unload Me
> > UserForm4.Show
> > End If
> >
> > The use of Ucase() means, that the user can
> > enter any combination of upper- and/or lower case
> > in the text box.
> >
> > --
> > Best Regards
> > Leo Heuser
> >
> > Followup to newsgroup only please.
> >
> > "gregork" <[email protected]> skrev i en meddelelse
> > news:[email protected]...
> > > Hi could someone show me the correct way of writing this code:
> > >
> > > If Me.TextBox1.Text = "Apples" or "pears" Then
> > > Unload Me
> > > UserForm4.Show
> > > End If
> > >
> > > thanks
> > > GK
> > >
> > >
> >
> >
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks