Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Textbox SetFocus (SSTab)


When I load my form, txtReason has the cursor, when I go to another tab in SSTab and then go back to the tab that contains txtReason, txtReason should automatically get the focus again; however, the focus doesn't happen. What am I missing?

VB Code:
Private Sub tabSettings_Click(PreviousTab As Integer)    Select Case PreviousTab        Case 0 'punch in / out reasons            txtReason.SetFocus    End SelectEnd Sub




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
SetFocus On A Textbox?
i use this code:

-------
Private Sub Form_Load()
Text1.SetFocus
ifile = FreeFile
str = ""
Open "e:inary" For Binary As #ifile
i = 1
l = 0
End Sub
------

and i get an error on the "text1.setfocus" line.....with the following text: "invalid procedure call of argument "

any idea???

SetFocus In TextBox!
A VB6 Form has, among other controls, a TextBox. I want that when the Tab key is pressed on the keyboard & the TextBox gets the focus, the entire text in the TextBox should get highlighted/selected. Right now what is happening is when the TextBox gets the focus, the entire text in the TextBox doesn't get highlighted/selected; instead the cursor positions itself at the very beginning of the text & blinks. So how would I make VB highlight/select the entire text in a TextBox when the TextBox gets the focus?

Thanks,

Arpan

Textbox SetFocus
I Created my own custom Textbox, but when i wanna compile an error msg popsup: Expected Function or variable

I think i the SetFocus function isn't an Boolean... But howelse can i create the SetFocus Function in an ActiveX control? (it works on runtime)


VB Code:
Public Property Get SetFocus() As Boolean    SetFocus = Text1.SetFocusEnd Property Public Property Let SetFocus(ByVal vNewValue As Boolean)    Text1.SetFocus = vNewValueEnd Property

Textbox Won't Setfocus
Fustration! Doing a simple check of a text box for valid data. Of course if the data is invalid I wan't to highlight the text and set the focus back to that text box. Done some reading of the faq's but no matter what I try the focus still stays on the next the text box that was tabbed or selected by user.

Textbox - Get Value Without Setfocus
Hi
In code i want to assign the value of a text box to a variable but the only way i seem to be able to do that in standard sub procedure is to:

dim int as integer

[Forms]![frmmain]![txtBox].SetFocus
int = [Forms]![frmmain]![txtBox].Text

Do i have to setfocus? I want to avoid this cos this seems to be opening the class module for this txtBox.

Your help much appreciated!

Thanks,
M



Edited by - AbbydonKrafts on 10/18/2006 8:24:00 AM

[newbie] Textbox SetFocus
Private Sub Form_Load()
txtInput.SetFocus
End Sub

i tried compiling and there is a invalid procedure call or arguments error... why is it so ?

Spinbutton And Textbox Setfocus
Among other controls on my frmMain form, I have a spinbutton control (SpinButton1), a textbox that shows the SpinButton value (SpinDigit) and a textbox (txtBes).

The purpose of this form, is to be able to insert different textstrings into a text array - Bes(0), Bes(1), Bes(2) and so on....

When the form appears, the SpinDigit text is "1".
After I have put some text into txtBes and click the right arrow on my Spinbutton, Bes(0) is saved with the correct text from txtBes, SpinDigit shows "2" and txtBes is set to "" (and ready for new input).

The problem here is that after I have clicked UP or DOWN on my SpinButton, I want to setfocus to a textbox.

This works every second time. The first time I click spinbutton, the focus is set to my textbox txtBes. At the same time the SpinDigit increments/decrements, depending on clicking right/left arrow.

But the next time I click either arrows on the SpinButton, a rectangular box appear around the arrows in my SpinButton control.
(As if it got focus or something....)

And the next time, the focus is set to my textbox txtBes (as it's suppose to do).

How do I get out of this jam??

Below is the code I have so far:

Code:
Private Sub SpinButton1_Change()
If SpinButton1.Value > Val(frmMain.txtNumberOf.Text) Then
SpinButton1.Value = Val(frmMain.txtNumberOf.Text)
Goto StopAid
End If

Bes(Val(frmMain.SpinDigit.Text) - 1) = frmMain.txtBes.Text
frmMain.txtBes.Text = ""

frmMain.SpinDigit.Text = Str(SpinButton1.Value)

If Bes(Val(frmMain.SpinDigit.Text) - 1) <> "" Then
frmMain.txtBes.SetFocus
frmMain.txtBes.Text = Bes(Val(frmMain.SpinDigit.Text) - 1)
End If
StopAid:
frmMain.txtBes.SetFocus
End Sub
What is wrong here ???
Hope I'll get some good ideas from you....

Problem With Setfocus. Textbox Not Getting It.
Hi all,
I have a form that has some textboxes and various other control on it. Fairly straightforward.
On opening it correctly sets the first textbox with focus, disables the second etc...
After one complete cycle through the program (ie, user enters a correct code, which enables the value textbox and sets focus, then accepts the transaction) the first box will not get focus.
If I step through the code it does get focus but running the code it does not (the gotfocus is never reached).

This i now getting very frustrating !!!!

I've attached the project and hopefully someone out there can offer some help.
The code should be fairly readable and the sub the should rest the focus is right at the bottom.
I've removed any path dependant file accesses.
When you run the program, after the splash enter
021909998
as the card number (has check digits and various other checks).
the value can be anything under 10000.

Please help. I'm getting desparate.

Getting Cursor At End Of Textbox With .Setfocus?
I'm making this name-builder for Quake3 games

If i click a button it puts some text in a textbox and then the cursor should be focussed on that textbox at the end of the line.
(thats what it should do),

but the cursor appears at the beginning of the line.

it would be a lot more userfriendly you know

yes i'm a noob in VB!

greetz born

SetFocus To Textbox On A Frame.
I have a Form with six InputBoxes on it. It also has two Frames on it with Boxes on them. On one Frame, I can edit the Tab Indexes of six more TextBoxes the way that I want to. On the other Frame, the TextBox and ListBox will only take numbers 3 and 4 respectively. I couldn’t SetFocus to them so I setfocus to the frame and then, on Frame2_Enter, I moved the focus to the ListBox. This works just fine except that I get an intermittent error. What should I be doing instead of this?

Textbox Setfocus Problem
Hello,

When I select an item in a Combobox, I want to automatically advance the cursor to a Textbox.


VB Code:
Private Sub Combo1_Click()If Combo1.Text = "Auto" Then   msgbox("you clicked Auto")End If[b]Text1.SetFocus[/b]End Sub


...but on 'Text1.SetFocus', I'm getting 'Invalid Procedure Call or Argument'.

Any ideas ?

How To Highlight The Textbox? .setfocus
Hello! how to highlight a particulart textbox when it .setfocus, i know it is {Sendkeys}, but i don't know what is the correct format. anyhelp plz.

Problem With Textbox And SetFocus
Hello,

I have noticed that a lot of people are having the same problem with Textbox SetFocus, so I thought I would post and see if we can get an answer.

I am using a User Defined Form in Excel. On the form I have a Frame (in which I have a two Textboxes) and two Control Buttons.

I have a list of products. For each product, I have to enter the number produced each month. Textbox #1 shows the Product ID and is locked. Textbox#2 shows the number of products made from the last month and is where I will enter data. The two control buttons are Finished and Cancel. When I have entered all the production data I will click on Finished and the data will be saved automatically to a master spreadsheet.

I would like to have focus on Textbox#2. As I enter data and hit [the Enter Key, Tab Key or Down Arrow] the program saves the number and goes to the next product and displays the product ID in Textbox 1 and the number made last month in Textbox 2.

The problem I am having is that after I hit the enter key, the focus goes to the Finished button. I would like to enter data - hit return - enter data - hit return... I used the command Textbox2.SetFocus, but this doesn't work. I have tried everything I can think of to get the focus back to Textbox 2 after [the Enter Key, Tab Key or Down Arrow] are pressed. I have even tried the Before_Update event:

Private Sub Textbox2_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Cancel = True
End Sub

This keeps the focus in Textbox2, but you can't click on the Command Buttons (Finished or Cancel).

I tried taking the Textbox out of the Frame, but that didn't work either.

I would appreciate any help with this problem. If you need more information, please let me know.

(perhaps setting the acitve control, or changing the current tab index pointer)

Jim

TextBox.SetFocus Problem
I am having trouble setting a textboxes setfocus. I have the following code:
Code:Private Sub txtFileNo_AfterUpdate()
    Dim strFileNo As String
    Dim intLen As Integer
    
    TextBox13.Text = txtYear.Text & "/" & txtFileNo.Text
    strFileNo = txtFileNo
    intLen = Len(strFileNo)
    Label2.Caption = CStr(intLen)
    
    If Label2 < 4 Then
    response = MsgBox("File No. suffix should be at least 4 digits ie.. 1234 or 0012", vbInformation)
    txtFileNo.SetFocus
    End If
End Sub


when the user enters less than 4 digits the msgbox appears and after clicking OK, the next textbox has the focus. any ideas

Can't SetFocus To A TextBox In Excel
Greetings! I am having trouble using "SetFocus" to get the Focus assigned to a TextBox in Excel (I've tried '97 & 2000). I have even used the example provided in the SetFocus Help file, as shown below. But when the command button is clicked, I get a "Run Time Error 438: Object doesn't support this property or method", and the debugger highlights the SetFocus line. Likewise, when typing the code manually, "SetFocus" does not pop up as an option for the textbox object. This is the code given in the Help File example (though only the first sub routine is relevant I think); it is of course assuming you have the textbox, commandbutton, and two labels:
=======
'Type SHIFT+ENTER to start a new line in the text box.

Private Sub CommandButton1_Click()
    'Must first give TextBox1 the focus to get line
     'count
    TextBox1.SetFocus
    Label1.Caption = "LineCount = " _
        & TextBox1.LineCount
    Label2.Caption = "TextLength = " _
        & TextBox1.TextLength
End Sub

Private Sub UserForm_Initialize()
    CommandButton1.WordWrap = True
    CommandButton1.AutoSize = True
    CommandButton1.Caption = "Get Counts"

    Label1.Caption = "LineCount = "
    Label2.Caption = "TextLength = "

    TextBox1.MultiLine = True
    TextBox1.WordWrap = True
    TextBox1.Text = "Enter your text here."
End Sub
=======
I'm not a VB/VBA pro, but I think I understand all the concepts involved, and am _really_ confused that MS's own example doesn't even work! I've also noticed that a TabIndex property is not listed for the textbox control, which isn't directly related, but also confuses me. In both cases, the Help Files (and my understanding/logic) seem to contradict what the program actually does.

In the end, all I want is for the textbox to be ready to receive input after macros have been executed. Any thoughts?

Thanks in advance for your help!

grover 1231

Need Help With Sheridan Tab And Textbox.Setfocus
--------------------------------------------------------------------------------
hi. i have 3 tabs in my form. in the form_load i set the tabindex for all other controls, ie. textbox, combobox, and list box. my question is, i would like to set the tabindex for other controls to the first, second, etc. if the user presses the second tab. this goes the same to the 3rd. my next question is regarding the textbox. i would like to set the cursor and position it to a textbox as soon as the user run the program. i got an error message stating invalid procedure call or argument. any help is greatly appreciated.

thanks in advance,
Archaven.

List Box Highlights A Row But Cannot SetFocus On A Textbox
I've noticed that when I use the following code in my listbox...


Code:
Private Sub List1_Click()
rst.Open "numbers", cnn, adOpenDynamic, adLockOptimistic
rst.MoveFirst
i = 0
Do Until rst.EOF Or i = (List1.ListIndex + 1)
i = i + 1
If i = 1 Then rst.MoveFirst
If i <> 1 Then rst.MoveNext
Loop
OrderNum = rst.Fields(0)
rst.Close
End Sub

-that when I run my program without even having a chance to click on my listbox it runs the above code. What I wanted to include at the end of that code is:


Code:
txtBox(0).SetFocus

but I get a run-time error 5. I believe its because the computer is not finished drawing up the form already. What adjustments can I do to the above to make sure that when a user clicks on the listbox it will bring back focus to that txtBox(0)!

Very appreciative and...

Setfocus On Textbox In Control Array
I have a control array of six textboxes and in another subroutine I would like to set the focus on the first textbox for user input.

textbox(0).setfocus is incorrect

Is there a simple way? You would think??

thanks.




Form2.Textbox.setfocus Called From Form1--again!
Hi all,

I know there are several other posts here on this topic, but I've read them and either I just don't understand or I'm running into a unique problem.

I'm calling form2 from a command button click event on form1 that autoruns when the Word template is opened as a new document. I want to set the focus to the first textbox on the first page of a multipage control on form2 using the setfocus method of the textbox.

The textbox is set to be visible and enabled and to have tabindex 0 at design time. None of these properties are altered at run time.

I tried setting the focus from the command button event handler (in form1) after I show the second form (form2 is loaded on initialize for form1):

Private Sub CommandButton_show_form2_Click()
form2.Show
textbox.setfocus
End Sub

I also tried setting the focus from the activate event handler on the second form:

private sub form2_activate()
textbox.setfocus
End Sub

I never got any errors--the focus simply doesn't get set.

Thanks for any help.

Position Cursor Within Textbox Data With Setfocus?
Is there a way to position the cursor within a textbox?  For instance, when a user clicks the "Add" button, a textbox is auto populated with the first 9 characters of an ID; the user enters the remaining 4.  But the cursor is positioned at the left of the text in the textbox instead of the right where the user really needs to be to begin entering.

I've tried not to use a setfocus and rely on tab order but it places cursor at the left instead of the right.  

I also formatted the text box to right justify, but again the cursor is placed to the left.

Any ideas?

Thank you,
Michelle

Access '97 Textbox Exit Setfocus Loop
Hi,

I have a problem with a textbox loop that I have created. I scan a number into a textbox then the scanner sends an exit command. This triggers the exit event, does the work to the scanned number and then sets focus back to the textbox. The problem is that at some stage I want to go and click another object on the form. Which means I trigger the exit event and that then sets focus back to the textbox. And there it sits.

Is there a way to cancel the event for a certain object. I can then use the mouse over event, when the mouse is moved over the other object and cancel the exit event for the textbox.

Thanks

Textbox.Enable = False And .SetFocus Mutually Exclusive ?
Hi all,

Here's my latest bit of stupidity:

Extract from code. It's part of a Spelling Game program I'm writing for my neices. (There is an Option Explicit in the Declarations section)

Code:
Private Sub cmdStart_Click()
Dim intFile As Integer
Dim intI As Integer
Dim intJ As Integer
Dim intLeft As Integer
Dim intTop As Integer
Static intWord As Integer
Timer1.Enabled = False
If cmdStart.Caption = "Finish" Then
Unload Me
Exit Sub
End If
'
' Remove the possibility of little fingers
' clicking twice
'
cmdStart.Visible = False
'
' If we're just starting, read the words to be spelt
' from file
'
If cmdStart.Caption = "Start Spelling" Then
intFile = FreeFile
'
' Read the Words into the Array
'
Open App.Path & "SpellTest.txt" For Input As #intFile
intI = 0
Do Until EOF(intFile)
ReDim Preserve strWord(intI)
Input #intFile, strWord(intI)
intI = intI + 1
Loop
Close intFile
cmdStart.Caption = "Next Word"
End If
'
' Set-up the Answer area
'
If intWord <> 0 Then
'
' Question Number
'
Load labNumber(intWord)
labNumber(intWord).Top = labNumber(intWord - 1).Top + labNumber(intWord - 1).Height
labNumber(intWord).Left = labNumber(0).Left
labNumber(intWord).Caption = intWord + 1
'
' Answer Area
'
Load txtAnswer(intWord)
txtAnswer(intWord).Top = txtAnswer(intWord - 1).Top + txtAnswer(intWord - 1).Height
txtAnswer(intWord).Left = txtAnswer(0).Left
txtAnswer(intWord).Text = ""
'
' Say it again command button
'
Load cmdRepeat(intWord)
cmdRepeat(intWord).Top = cmdRepeat(intWord - 1).Top + cmdRepeat(intWord - 1).Height
cmdRepeat(intWord).Left = cmdRepeat(0).Left
'
' Marking command button
'
Load cmdMark(intWord)
cmdMark(intWord).Top = cmdMark(intWord - 1).Top + cmdMark(intWord - 1).Height
cmdMark(intWord).Left = cmdMark(0).Left
'
' Result of marking
'
Load labMark(intWord)
labMark(intWord).Top = labMark(intWord - 1).Top + labMark(intWord - 1).Height
labMark(intWord).Left = labMark(0).Left
'
' Disable the previous answers from being changed
'
labNumber(intWord - 1).Enabled = False
[b]txtAnswer(intWord - 1).Enabled = False[/b]
labMark(intWord - 1).Enabled = False
'
' In case little fingers are inquisitive
' don't let them touch the previous buttons
'
cmdRepeat(intWord - 1).Visible = False
cmdMark(intWord - 1).Visible = False
End If
'
' Move the Teacher to a suitable place on the Screen
'
intLeft = labMark(intWord).Left + labMark(intWord).Width
intTop = labMark(intWord).Top + labMark(intWord).Height - (Teacher.Height / 2)
Teacher.MoveTo intLeft, intTop
'
' Display the controls for this word
'
labNumber(intWord).Visible = True
txtAnswer(intWord).Visible = True
cmdRepeat(intWord).Visible = True
cmdMark(intWord).Visible = True
'
' Put the cursor into the answer area
'
[b]txtAnswer(intWord).SetFocus[/b] -----------> This is the problem Line
'
' intCurrent is the current word pointer
'
intCurrent = intWord
intWord = intWord + 1
'
' Speak the Word to be spelt
'
Teacher.Play ("Read")
Call SpeakTextT("Spell...")
Call SpeakTextT(strWord(intCurrent) & "...")
Call SpeakTextT(strWord(intCurrent))
Timer1.Enabled = True
End Sub

The idea is that I create a label, a Textbox (for the answer) a couple of buttons and another label - all control arrays - and the computer speaks the word to be spelt. The cursor is in the textbox ready for the answer to be typed.

I disable / hide previous array elements to show they've been finished (and to stop unwanted clicking and typing in the wrong place - the clients are 5 and 7 years old)

The first and second time through (ie when intWord is 0 and 1) it all goes fine.

However, when I create element intWord = 2 and disable txtAnswer(intWord - 1) and subsequently try to .SetFocus on txtAnswer(intWord) it fails with a "Run time error 5 Invalid Procedure Call or Argument" at the line highlighted above. (.SetFocus)

Debug shows the value of intWord as 2 at the point of failure.

If I comment out the .Enable = False on txtAnswer (the other highlighted line) the .SetFocus works fne.

Clearly, .Enable = and .Setfocus are fairly fundamental things to do, so I've obviously got something wrong somewhere.(That's why I posted all the relavent code rather than a snippet)

If anything, because I treat things differently for element zero, I'd expect the problem to be with the first non-zero element, rather than the second one! I'd appreciate any help in finding out where the problem lies.

It's on ME, I'm using Mircosoft Agent 2.0, and all controls are standard VB except for the control buttons for which I'm using the Forms 2 Object Library, in case that makes any difference)

Regards
Doug

How To Setfocus A Textbox In Userform With Properties MDIChild=true
Hi every body
How to setfocus a textbox in userform with properties MDIChild=true?
Can you help me , please
Thanks a lot

Form2.Show VbModal&lt;&lt;&lt;setfocus To A Textbox On Another Form! Help!
i have two forms form1 and form2

the form2 is over the form1 and i call it by clicking on a command button with the following code


Code:
Private Sub Command1_Click()
Form2.Show vbModal
End Sub


so the form2 is over the other and is active until closed....
now i have a command button on form2....
for some reason I want that commandbutton to setfocus on a textbox on form1... but it shows an error! coz i have called form2 as vbModal...


Code:
Private Sub Command1_Click()
Form1.Text1.SetFocus
End Sub

is there a way out of this!
Remember! i want form2 to always remain on top!

thx in advance

From Form2's Grid Control's Text To Form1's Textbox Setfocus Is Not Working
Friends

Have a look and try to help me.

In the form1 place one textbox.

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF9 Then
Form2.Show
End If
End Sub

in the form2 place a datagrid or flexgrid and a datacontrol select any table just to get the values inthe grid. after that.

Private Sub DataGrid1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Me.Hide
Form1.Text1.Text = Me.DataGrid1.Text
End If
End Sub

Try this once you press the enter key in the grid. form2 will hide and the form1 is not enabling.

i tried by giving form1.text1.setfocus etc...
but no use can anyone set a focus from form2 to form1 by using the above code.

Thanks
Sathyguy

SSTab's And Textbox's
Here's another silly question from a newbie &lt;grin&gt;

I've got a form with a 4 tab SSTab, and a Toolbar with a print button that needs to print whatever's in the current textbox.

How do I determane which textbox is active (One textbox per SSTab)?

- Brad

Sstab And Textbox Validation
I have a sstab with 6 tabs. I have a few textboxes on one of the tabs with range checking. When I go from textbox to textbox, validation event executes. But when I am in a textbox and click a tab, validation doesn't execute. Sstab causesvalidation property is set to true. How can I make validation occur before going on to the next tab? Thanks.

Clear Textbox On Only One SSTab *Resolved*
I would like to clear the textboxes on ONE SSTab,

However when I use a For Each control, it clears all of the textboxes on all of the tabs.

I have the textboxes within a frame, BUT I would rather not make them into an array.

Anyone have any ideas?

Detect Pressing The Tab In A Textbox On An SSTAB Control
For the life of me, I CAN NOT figure out how to do it...

Any guidance?

I've tried key press, key up, key down....

I'm stuck...

Thanks!

Validate Event On Textbox Within Sstab Not Firing When Changing Tabs!
I've noticed an odd problem with VB6 where validate events won't fire from text boxes (haven't tried any other controls, though). If I click on a different control like a command button or another textbox, the original text box validate event fires, but if I select another tab, the validate event for the text box does NOT fire! The sstab causesvalidation is set to true. Anyone have any workarounds for this? If not, then I'll have to validate all of the text boxes manually when I want to close the form and save the data. Yeecccchhh....

Thanks for your help!

Bill

HELP! Line 31: Class TabDlg.SSTab Of Control SSTab
One of my forms has tabs and I loaded Class TabDlg.SSTab from Project..Components..Microsoft Tabbed Dialog Control 6.0

And it was working fine until today. I added a new form to my project today and ran my program just fine. I saved it and now when I try to open my program I keep getting the error:
Line 31: Class TabDlg.SSTab of control SSTab.
If I try to load it, the error I get is:
Name Conflicts with existing module, project or object library.
I can't figure out what this means.
HELP!

Swithcing Contents Of An SSTab To Another SStab
Greetings,

I'm using SSTab, and I need to make it so that tab 1 has the contents of tab 4.

So far there has not been an easy way to do it. Any cutting and pasting just pastes over the whole tab, and I don't feel like creating every object in tab 4 all over again in tab 1.

It seems like there must be an easy trick; anyone have any ideas?

Thank you,
Jim

SSTab Question Again, How To Loop Through SSTab?
Hi, there, I have a problem with SSTab, I don't know how to loop through the SSTab control using Len of SSTab as ENd loop. see the code below. I have 8 tabs, try to loop through the tab to detect which tab user clicks, if user clicks first tab, I want to use case to make func call to class and pass that variable

TName = "AssetElectronics"

But I got variable required, can't assign to this expression, highlighting

For SSTabGear.TabIndex = i To Len(SSTabGear.Tab - 1)

Any idea? I have tried several times, trying to find how to approach the len of SStab? Thanks in advance!

gina



Private Sub SSTabGear_Click(PreviousTab As Integer)

Dim GearManager_get As GearManager
Set GearManager_get = New GearManager
Dim TName As String

Dim i As Integer
i = 0
For SSTabGear.TabIndex = i To Len(SSTabGear.Tab - 1)
Select Case SSTabGear.Tab
Case 0
TName = "AssetElectronics"
Case 1
TName = "AssetElectrical"
Case 2
TName = "AssetSails"
Case 3
TName = "AssetRigging"
Case 4
TName = "AssetHardware"
Case 5
TName = "AssetGalley"
Case 6
TName = "AssetSafety"
Case 7
TName = "AssetMisc"
End Select

Next



'Func call GEARMANAGER getElectronics
GearManager_get.getElectronics (TName)


End SubFor SSTabGear.TabIndex = i To Len(SSTabGear.Tab - 1)

SetFocus
Hi,
I created my own dialog window and its purpose is to replace vb's inputbox function.

But i cannot get the cursor to be in the Textbox (setFocus) when the dialog get focus (show)

Any thoughts?

Thanks.

Setfocus
When I load the program I want to have the blinking cursor in the txtUser box. Any idea on how to do this?

Is There A Way Around .Setfocus
I'm writing a program in access which takes values from several txt and
combo boxes and puts them into a database. At the moment I'm getting
an error saying object does not have focus, to fix it I would have to add
txtbox.setfocus etc all over the place which will take some time and
make me code hard to read. I was wondering if there is a way around
this?

Thanks

SetFocus Help
Can any one help, sooo confussd i keep getting run time error 2185 come up saying "you cannot reference a property or method for a control unless the control has the focus" anyone got any soloutions to this problem?

SetFocus
I'm trying to set focus to a certain TextBox but all I get is one TextBox skipped.

A form with 4 TextBoxes.

Code:
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox4.SetFocus
End Sub
There is nothing else on my form. No macros either.

After exiting TextBox1, cursor goes to ... TextBox3, not TextBox4.
Without SetFocus statement, cursor goes as expected to TextBox2.
With debug enabled and step by step run, I discovered that TextBox1_Exit event is executed twice: it's fired by SetFocus method .

Any ideas on what am I doing wrong?

Thanks

Setfocus?
Hi

I have a userform which has a 4 tab multipage each has a link to a corresponding sheet and the sheet has a link back to the userform.. Can I use setfocus to take me to the sheets corresponding multipage? Setfocus returns an error.. I assume this is because the userform has not yet loaded!

Code so far...

Sub bhamteamsheethide()
Sheets("Bhamteam").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("Centre Finder").Select
ThisWorkbook.Application.Visible = False
frmcentrelocate.Show
End Sub

Ta

Setfocus
Hi

I was wondering how to change the focus so that it is not on the richtextbox.

(I only have a richtextbox as an object on my from and nothing else .It's so annoying to see the cursor in it so just trying to change it.
I know that I can only set focus to visible objects so I tried to put another label same colour with the background of my form which basically has no functionality and set the focus to that label but didn't work!)

Any ideas???

Thanks

SetFocus Help
I am trying to write a simple code snipet to set the focus on my OK cmd button after the text box value changes and I am having trouble with syntax I guess. I have:

Private Sub txtCOM_Change()
cmdOK.SetFocus
End Sub

and I keep getting an error
Run-time error '5':
Invalid procedure call or argument

Setfocus
ok, the text1.setfocus doesnt work, i have no idea why, when i run it says invalid procedure call or argument. i just dopnt get y. any ideas?

nevermind, when i added the line; Show infront of it, it worked. thanks anyways

How To Setfocus
I had a windowless VB program that runs on top of an application. Half way it will promt the user with an inputbox for further input. I am encountering a problem where now both the app and the VB program are in foreground but the focus remains with the application . How can I resolve this? I need the input box to be in focus and in foreground.

SetFocus
Code:
Private Sub Form_Load()
Text2.SetFocus
End Sub
why the setfocus cannot be use here?

SetFocus?
hi all, got a slight problem, this is my code:


Code:
Private Sub Form_Load()
txtPassword.SetFocus
End Sub
i want the textbox to have the control on the form, so the user just has to type without clicking the textbox, but it's not working and im getting:

Invalid Procedure Call or Arguement

any ideas?

About Setfocus
Hi
I wanted to know what the 'set focus' command is used for. i found that command being used in a tutorial but it's significance not explained.
An example would be apreciated.
Thanks

And about 'tab index'
in a program i've witten , i want a particular button to be the default one after a certain command is executed. but that's not the case.
the button below it is selected.
Though i've changed their tabindex, it doesnot work.

PS: If anyone doesnot understand my second problem, i'll post the program here.

Setfocus
Whenever i try to setfocus onto a command button, i get the following error, 'Invalid Procedure call or argument' how can i stop getting this?

Setfocus
I am using this code to keep my form in front of the other forms:

SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE

Text1 used to have focus on form load but when I started using that code it quit giving the focus to text1. I thought it would work to write in the form load procedure:
text1.setfocus
but that returns an invalid procedure.

Does anyone know how I can do this? Probably easy but I'm stumped. Thanks in advance

Help W/ Setfocus
i'm having trouble setting the focus to one of my text boxes after choosing an item from a combo box. after i click the item in the combo box it highlights it and won't allow me to set the focus to my text box.

txtAmount.SelStart = 0
txtAmount.SelLength = Len(txtAmount.Text)
txtAmount.SetFocus

is what i have now to set the focus to my textbox, but it doesn't, it the text in my combo box stays highlighted and when i type it replaces the text in the combo box.

thanks
gary

Copyright © 2005-08 www.BigResource.com, All rights reserved