|
-
Apr 6th, 2004, 03:59 PM
#1
Thread Starter
Fanatic Member
dropdown combos
Any 1 recalls the simpler way to not allow the user to type something of his own in a drop down box.. only the items chosen?
Thanks in advance...
-
Apr 6th, 2004, 04:00 PM
#2
Change the Style property to 2.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Apr 6th, 2004, 04:02 PM
#3
Fanatic Member
Change the Style property
"Knowledge is gained when different people look at the same information in different ways"
- Louis Pasteur
-
Apr 6th, 2004, 04:14 PM
#4
Thread Starter
Fanatic Member
to 2
When I change the style property to 2... it would work ok... The problem is that blank fields or fields with Null values would kick an error... Any workaround...
-
Apr 6th, 2004, 04:20 PM
#5
Re: to 2
Originally posted by Lafor
When I change the style property to 2... it would work ok... The problem is that blank fields or fields with Null values would kick an error... Any workaround...
What is the source of the data? Why can't you filter it befeore you load the combobox?
-
Apr 6th, 2004, 04:25 PM
#6
Thread Starter
Fanatic Member
Yes
Here is how I do it
From a loaded recordset
cmbMfgTextRecvd.Text = .Fields("MfgTextRecvd") & ""
Still get the error.. I don't really want to put a blank in there...
-
Apr 6th, 2004, 05:23 PM
#7
Do something like
VB Code:
If .Fields("MfgTextRecvd") > "" Then
cmbMfgTextRecvd.AddItem .Fields("MfgTextRecvd")
End If
-
Apr 6th, 2004, 05:24 PM
#8
Here is a public function that I wrote a while ago that can handel that.
VB Code:
Option Explicit
Private Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Const CB_FINDSTRINGEXACT = &H158
Private Const CB_FINDSTRING = &H14C
Public Function SearchCBO(ByRef cboCtl As ComboBox, ByVal sSearchCriteria As String, Optional ByVal bLIKE As Boolean) As Long
'<RR 08/08/2003 - VB/OUTLOOK GURU>
On Error GoTo No_Bugs
If bLIKE = False Then 'EXACT MATCH
SearchCBO = SendMessageStr(cboCtl.hwnd, CB_FINDSTRINGEXACT, 0&, ByVal sSearchCriteria)
Else 'LIKE MATCH
SearchCBO = SendMessageStr(cboCtl.hwnd, CB_FINDSTRING, 0&, ByVal sSearchCriteria)
End If
Exit Function
No_Bugs:
MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbInformation
Exit Function
Resume 'FOR DEBUGGING
End Function
Usage...
VB Code:
'...
'...
'...
cmbMfgTextRecvd.ListIndex = SearchCBO(cmbMfgTextRecvd, .Fields("MfgTextRecvd") & "", False)
If it exists it will change the combo to the item and if it doesn't then it
will set the combo to a listindex of -1 which is no selection.
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 7th, 2004, 09:26 AM
#9
Thread Starter
Fanatic Member
Thanks
Thanks much to all of you.. for responding so promptly..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|