Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Keypress Textbox


Hi all,

I have a userform with a cmdButton, lstBox, and txtBox - the userform
acts as a search tool for part numbers;


Code:
--------------------

Public Function searchPart(partNumber)

Dim i%, rowParts%, Count As Integer

Select Case frmMain.cbxSection.Value

Case "Heading": rowParts = 7
Case "Briv Cartridge": rowParts = 9
Case "Pace": rowParts = 11
Case "Thread Rolling": rowParts = 13
Case "Podding": rowParts = 15

End Select

ActiveWorkbook.Sheets("RelationalData").Activate
Range("A1").Select

If partNumber < "" Then

frmSearch.lstResult.Clear
i = 3: Count = 0
Do
If InStr(1, Cells(i, rowParts).Value, partNumber, vbTextCompare) < 0 Then
With frmSearch.lstResult
.AddItem Cells(i, rowParts).Value
Count = Count + 1
End With
End If
i = i + 1
Loop Until Cells(i, rowParts).Value = ""

If Count = 0 Then
With frmSearch.lstResult
.AddItem "No Match Found"
End With
End If

End If

frmSearch.lstResult.TopIndex = 1
frmSearch.lstResult.ListIndex = 0
frmSearch.lstResult.SetFocus

End Function

--------------------


I am trying to make the form more usable, so when I press enter whilst
in the txtBox it will call my function above - I have tried various
methods but everytime I press 'enter' it moves focus to the cmdButton.

Any ideas or suggestions?

Thanks


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=520474

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Keypress Textbox

Hi, If I did you understand good so go to Commandbutton propertis and set
Deafult as False or paste it into the code like this:

CommandButton1.Default = True

Then if you hit the ENTER the Commandbutton would not have the focus.

Henrich

€žgti_jobert" napÃ*sal (napÃ*sala):


Hi all,

I have a userform with a cmdButton, lstBox, and txtBox - the userform
acts as a search tool for part numbers;


Code:
--------------------

Public Function searchPart(partNumber)

Dim i%, rowParts%, Count As Integer

Select Case frmMain.cbxSection.Value

Case "Heading": rowParts = 7
Case "Briv Cartridge": rowParts = 9
Case "Pace": rowParts = 11
Case "Thread Rolling": rowParts = 13
Case "Podding": rowParts = 15

End Select

ActiveWorkbook.Sheets("RelationalData").Activate
Range("A1").Select

If partNumber < "" Then

frmSearch.lstResult.Clear
i = 3: Count = 0
Do
If InStr(1, Cells(i, rowParts).Value, partNumber, vbTextCompare) < 0 Then
With frmSearch.lstResult
.AddItem Cells(i, rowParts).Value
Count = Count + 1
End With
End If
i = i + 1
Loop Until Cells(i, rowParts).Value = ""

If Count = 0 Then
With frmSearch.lstResult
.AddItem "No Match Found"
End With
End If

End If

frmSearch.lstResult.TopIndex = 1
frmSearch.lstResult.ListIndex = 0
frmSearch.lstResult.SetFocus

End Function

--------------------


I am trying to make the form more usable, so when I press enter whilst
in the txtBox it will call my function above - I have tried various
methods but everytime I press 'enter' it moves focus to the cmdButton.

Any ideas or suggestions?

Thanks


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=520474


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Keypress Textbox


Sorted Henrich, that works perfectly!

Thanks alot!

Henrich Wrote:
Hi, If I did you understand good so go to Commandbutton propertis and
set
Deafult as False or paste it into the code like this:

CommandButton1.Default = True

Then if you hit the ENTER the Commandbutton would not have the focus.

Henrich

€žgti_jobert" napÃ*sal (napÃ*sala):


Hi all,

I have a userform with a cmdButton, lstBox, and txtBox - the

userform
acts as a search tool for part numbers;


Code:
--------------------

Public Function searchPart(partNumber)

Dim i%, rowParts%, Count As Integer

Select Case frmMain.cbxSection.Value

Case "Heading": rowParts = 7
Case "Briv Cartridge": rowParts = 9
Case "Pace": rowParts = 11
Case "Thread Rolling": rowParts = 13
Case "Podding": rowParts = 15

End Select

ActiveWorkbook.Sheets("RelationalData").Activate
Range("A1").Select

If partNumber < "" Then

frmSearch.lstResult.Clear
i = 3: Count = 0
Do
If InStr(1, Cells(i, rowParts).Value, partNumber, vbTextCompare) <

0 Then
With frmSearch.lstResult
.AddItem Cells(i, rowParts).Value
Count = Count + 1
End With
End If
i = i + 1
Loop Until Cells(i, rowParts).Value = ""

If Count = 0 Then
With frmSearch.lstResult
.AddItem "No Match Found"
End With
End If

End If

frmSearch.lstResult.TopIndex = 1
frmSearch.lstResult.ListIndex = 0
frmSearch.lstResult.SetFocus

End Function

--------------------


I am trying to make the form more usable, so when I press enter

whilst
in the txtBox it will call my function above - I have tried various
methods but everytime I press 'enter' it moves focus to the

cmdButton.

Any ideas or suggestions?

Thanks


--
gti_jobert

------------------------------------------------------------------------
gti_jobert's Profile:

http://www.excelforum.com/member.php...o&userid=30634
View this thread:

http://www.excelforum.com/showthread...hreadid=520474




--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=520474

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
keypress Luis Excel Programming 0 January 3rd 06 03:01 PM
Keypress broogle Excel Programming 7 July 7th 05 05:20 AM
Edit Textbox using KeyPress vba code in Access Arno Excel Programming 3 February 23rd 04 11:57 AM
Keypress nest Garry Jones Excel Programming 4 October 21st 03 02:56 PM
keypress Garry Jones Excel Programming 2 October 17th 03 09:47 AM


All times are GMT +1. The time now is 09:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"