Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 19th, 2004, 01:28 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default default selection in a datacombo

Hi i need some help on working with a datacombo..

what i am trying to do is set a default selection in a datacombo. i.e. if my datacombo is bound to a column containing id's like 1,2,3 then i want that id 3 should come as selected by default.

any help on this will be appreciated
Reply With Quote
  #2 (permalink)  
Old August 19th, 2004, 06:55 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

If you look at the form in design view and look at your combobox's property window, you can set a default value there.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
  #3 (permalink)  
Old August 21st, 2004, 12:00 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
Thanx for replying to my posting

But actually i was looking for a way for dynamically setting the default selection in a datacombo. Found a solution for it. It can be done as follows:

After populating the datacombo, set
datacomboNAME.Text = strDescription

where strDescription is the description field corresponding to the id that we wish to select by default

Thanx anyway
Reply With Quote
  #4 (permalink)  
Old August 23rd, 2004, 07:04 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

No, that's not how you set a default in code. What you did was to actually assign the textbox a value. It just so happens the value is strDescription.

To set a default with code it's

Me.datacomboNAME.DefaultValue = strDescription

What's the difference?

If you use the .DefaultValue method like I did, then:

You're on the last record, say number 10.
You scroll forward to add a new record.
You start typing in a field.
Your new record, number 11, is created.
Your datacombo gets the default automatically.

OR

You're on the last record, say no. 10.
You scroll forward to add a new record.
You change your mind and scroll back.
Your new record, would have been no. 11, is NOT created.
You still have only 10 records.

If you do it your way.

You're on the last record, say number 10.
You scroll forward to add a new record.
Your datacombo has no default. You literally assign it a value.
You start typing in another field.
Your new record, number 11, is created.

OR

You're on the last record, say no. 10.
You scroll forward to add a new record.
Your datacombo has no default. You literally assign it a value.
You change your mind and scroll back.
Your new record, no. 11, is STILL created, but it only has one field filled out, i.e. the datacombo.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
  #5 (permalink)  
Old August 24th, 2004, 11:53 PM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Thanx for explaining it to me. But I was not able to find the 'defaultValue' property !!
Reply With Quote
Reply


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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding Dataset to DataCombo in .NET TokenBug ADO.NET 4 September 29th, 2006 05:02 AM
Sending a message to a DataCombo Box control vikramrj Pro VB 6 0 June 3rd, 2006 12:47 PM
Set Default selection in ListBox nmreid Classic ASP Basics 0 January 20th, 2006 04:49 PM
About the Datacombo momowu0701 VB.NET 2002/2003 Basics 0 November 25th, 2004 10:56 PM
Problem of the datacombo momowu0701 VB How-To 0 March 14th, 2004 11:58 PM



All times are GMT -4. The time now is 01:22 PM.


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