Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 13th, 2007, 09:24 AM
Authorized User
 
Join Date: Jan 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cnkumar74 Send a message via Yahoo to cnkumar74
Default Combo Box

Dear All,

     I have a Combo Box (Combo2) and some values are stored in it.I also have a Button (Get Details).When the form is Loaded, this button will not be enabled.Only when we select any value from the said Combo, this button will be enabled. I wrote a

Code:
Private Sub cboCompNo_Change()
 If Combo2.Value.Selected = '' Then    <------------- Doubt 
    Command2.Enabled = True
 End If
End Sub
 when running the application, I am getting a error message. Is this code correct? The combo contains Numbers.

Any one who gives an help in this matter will be appreciated...............

 Nanda Kumar

 
Old February 13th, 2007, 09:54 AM
Authorized User
 
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Try this

Private Sub cboCompNo_Change()
 If Combo2.SelectedIndex <> -1 Then
    Command2.Enabled = True
 End If
End Sub



 
Old February 15th, 2007, 02:02 AM
Authorized User
 
Join Date: Jan 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cnkumar74 Send a message via Yahoo to cnkumar74
Default


Tried this code. But not successful....Any other way by which I can accomplish this task....




Nandan






Quote:
quote:Originally posted by HaveHave2222
 Hi,

Try this

Private Sub cboCompNo_Change()
If Combo2.SelectedIndex <> -1 Then
    Command2.Enabled = True
End If
End Sub



 
Old February 26th, 2007, 08:02 AM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think you should try changing the code in

Private Sub cboCompNo_Change()

If not isnull(Combo2) Then
    Command2.Enabled = True
else
    Command2.Enabled = False
End If

End Sub

I'm not sure about this, but give it a try...

 
Old February 26th, 2007, 08:05 AM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, change it to

Private Sub cboCompNo_Change()

If not isnull(Combo2) Then
    Me.Buttonname.Enabled = True
else
    Me.Buttonname.Enabled = False
End If

End Sub

if it is the action button you want to enable...

 
Old February 26th, 2007, 08:06 AM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm being to quick here...

make sure you put the code on the after update event of the combo box where you select the values...

 
Old April 3rd, 2007, 12:10 PM
Authorized User
 
Join Date: Mar 2006
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Raghunathan
Default

hi
sorry for a delayed reply..

try this..

Private Sub Combo2_Click()
   If Combo2.ListIndex = -1 Then Command1.Enabled = False Else Command1.Enabled = True
End Sub

Regards,
Raghu
 
Old April 3rd, 2007, 12:12 PM
Authorized User
 
Join Date: Mar 2006
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Raghunathan
Default

hi,

Change event of the ComboBox will fire, when start typing in the textbox portion of the ComboBox

Click event will fire whenever u select any item from the combobox dropdown.

ListIndex is the property which will return the index of the Selected Item in the ComboBox, if no item is selected it will return -1.

This is the reason why all code that u've tried didnt work

Regards,
Raghu





Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate a text box from a combo box value dnf999 Access VBA 7 February 6th, 2012 02:24 PM
Combo box to display items from parent combo box Gini Visual Studio 2008 0 June 18th, 2008 12:30 AM
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Combo box choice creating filtered combo box stevensj5 Access 11 September 13th, 2007 11:33 AM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.