• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • 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
thanks
0
jacobg12
Asked:
jacobg12
  • 4
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
You can simply set its Text property.

DataCombo1.Text = "oranges"
0
 
Éric MoreauSenior .Net ConsultantCommented:
Is this what you wanted?
0
 
Éric MoreauSenior .Net ConsultantCommented:
You have to accept it now if it is working!
0
 
jacobg12Author Commented:
emoreau ,its not working little busy off late
0
 
É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"
        .Refresh
    End With
   
    With DataCombo1
        Set .RowSource = Adodc1.Recordset
        .ListField = "CategoryName"
    End With
   
    Text1.Text = "Confections"
End Sub
0
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

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

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