• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

how to set a default value on datacombo

i want to display a paricular name in the datacombo control by default from the list,without the user using it
for ex:the datacombo is having the title"oranges" on it by default,without the user clicking the combo
emoreau(hope i spelt it right) help me
refered by bindu10
  • 4
1 Solution
Éric MoreauSenior .Net ConsultantCommented:
You can simply set its Text property.

DataCombo1.Text = "oranges"
Éric MoreauSenior .Net ConsultantCommented:
Is this what you wanted?
Éric MoreauSenior .Net ConsultantCommented:
You have to accept it now if it is working!
jacobg12Author Commented:
emoreau ,its not working little busy off late
Éric MoreauSenior .Net ConsultantCommented:
Yes it is!

Place an ADODC control, a DataCombo control, a TextBox and a command button control on a form (without changing any properties). Then paste this code to your form (Do not forget to change the path to the Nwind database):

Option Explicit

Private Sub Command1_Click()
    DataCombo1.Text = Text1.Text
End Sub

Private Sub Form_Load()
    With Adodc1
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Program Files\Microsoft Visual Studio\VB98\Nwind2000.mdb;Persist Security Info=False"
        .RecordSource = "SELECT * From Categories"
    End With
    With DataCombo1
        Set .RowSource = Adodc1.Recordset
        .ListField = "CategoryName"
    End With
    Text1.Text = "Confections"
End Sub
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now