A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Naming userform makes Textbox control malfunction



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old November 17th 08, 03:21 PM posted to microsoft.public.outlook.program_forms
MarceepooNu
external usenet poster
 
Posts: 17
Default Naming userform makes Textbox control malfunction

I posted this question yesterday (by mistake, I think) in
Outlook-Programming-VBA, at 11/16/2008 10:35 AM PST. I should have posted it
here, I think. If it is improper for me to post it here now, please don't
read any further and accept my apology.

The code below works fine in a form named "UserForm", but when I tried to run
the same code in another form (frmUserForm2's "Initialize" sub), nothing
appears in the textboxes.

I copied the sample code from the Outlook VBA help page named: "Cut, Paste
Methods, TextBox Control Example". I created two forms in my Outlook
VbaProject.Otm; one form was named: UserForm and the other was named
frmUserForm2, and I put the identical code in both, except for the name of
the form.

The sample code is set forth below, except that I changed the first line of
the code from...
Private Sub UserForm_Initialize()
to...
frmUserForm2
because I named the form: frmUserForm2

The code works fine in the form named "UserForm", but when I tried to run
the same code in frmUserForm2's "Initialize" sub, nothing appears in the
textboxes.
Question #1: I can't figure out why changing the name of the form prevents
the code from working.
Question #2: I have noticed that if I remove a form from the project, and
thereafter create a new form and give it the same name as the form that I
removed, I get an error message: "Path/file access error. Why does this
occur, and how can I fix it?


Private Sub frmUserForm2_Initialize()
TextBox1.Text = "From TextBox1!"
TextBox2.Text = "Hello "

CommandButton1.Caption = "Cut and Paste"
CommandButton1.AutoSize = True
End Sub

Private Sub CommandButton1_Click()
TextBox2.SelStart = 0
TextBox2.SelLength = TextBox2.TextLength
TextBox2.Cut

TextBox1.SetFocus
TextBox1.SelStart = 0

TextBox1.Paste
TextBox2.SelStart = 0
End Sub


--
MarceepooNu
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programmatically set a textbox control to read-only Lucy Outlook - Using Forms 2 August 28th 08 09:26 AM
Changing font colour of Textbox control willwong Outlook - Using Forms 3 November 12th 07 05:18 PM
Help~ Inbox empty after PC malfunction Kathy Outlook Express 4 October 12th 06 07:50 AM
IE Malfunction Weldy Outlook Express 3 April 30th 06 03:33 AM
Recent OExpress malfunction & fix tR2 Outlook Express 8 April 21st 06 04:25 PM


All times are GMT +1. The time now is 02:08 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.