The problem is i want to show a default value on form load in comobo box txt5, user dont need to click on it.
am using goto focus and lost focus to grab data from data base .
I need your suggestion that how to populate a combo txt5 on load like when form load the txt5 combo can show
data from the select query .

 Private Sub txt5_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txt5.GotFocus
        Try
            txt5.Items.Clear()

                myRead.myfill("Select DETAILACCOUNT from tb_MYCHARTOFACCOUNT")

            End If
            Dim rc, lr As Integer
            lr = myRead.dt.Rows.Count - 1
            For rc = 0 To lr
                txt5.Items.Add(myRead.dt.Rows(rc).Item(0))

            Next
        Catch exc As Exception
            'MsgBox(exc.Message)
        End Try
    End Sub

    Private Sub txt5_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txt5.LostFocus
        If txt5.Text <> "" Then
            fillvcode()

        End If
    End Sub

Use the load event handler. Double-Click on an empty spot on the form and a code stub for the handler will be shown in the code window.

    Try
        txt5.Items.Clear()
            myRead.myfill("Select DETAILACCOUNT from tb_MYCHARTOFACCOUNT")
        End If

are you sure you didn't encounter any error on your code? I think it is going to perform the catch statement because you have endif without using If.

@ Geek Please i have posted just a part of code if is missed :)

and thank you tinstaafl and GeekPlease

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.