Values won't show to labels when I change the ComboBox data valuethe connection cannt be used to perform this operation. It may closed or not valid in this context error in vb6how to change the label field at run time in vb6?how to solve Runtime error 3704 in visual basic 6.0?Adding both text and an ID value to a VB6 comboboxChange Label to Textbox in VB6How to show data from database on datagridview comboboxHow to add row value to the comboboxCombobox change height vb6?populate values in textbox if select combobox vb6make datagrid take value from combobox in vb6

Can an opamp have its own voltage regulator?

Do items with curse of vanishing disappear from shulker boxes?

What does the output current rating from an H-Bridge's datasheet really mean?

I sent an angry e-mail to my interviewers about a conflict at my home institution. Could this affect my application?

What is the context for Napoleon's quote "[the Austrians] did not know the value of five minutes"?

How do I become a better writer when I hate reading?

Is fission/fusion to iron the most efficient way to convert mass to energy?

Cant bend fingertip when finger is straight

Are athletes' college degrees discounted by employers and graduate school admissions?

How do credit card companies know what type of business I'm paying for?

What things do I only get a limited opportunity to take photos of?

How would Japanese people react to someone refusing to say “itadakimasu” for religious reasons?

Why can't we feel the Earth's revolution?

Can Dive Down protect a creature against Pacifism?

Idiom for 'person who gets violent when drunk"

Can artificial satellite positions affect tides?

For Saintsbury, which English novelists constituted the "great quartet of the mid-eighteenth century"?

Is it unethical to quit my job during company crisis?

Boss making me feel guilty for leaving the company at the end of my internship

How to avoid offending original culture when making conculture inspired from original

Why not make one big CPU core?

Why is Skinner so awkward in Hot Fuzz?

How to ask if I can mow my neighbor's lawn

Should I email my professor to clear up a (possibly very irrelevant) awkward misunderstanding?



Values won't show to labels when I change the ComboBox data value


the connection cannt be used to perform this operation. It may closed or not valid in this context error in vb6how to change the label field at run time in vb6?how to solve Runtime error 3704 in visual basic 6.0?Adding both text and an ID value to a VB6 comboboxChange Label to Textbox in VB6How to show data from database on datagridview comboboxHow to add row value to the comboboxCombobox change height vb6?populate values in textbox if select combobox vb6make datagrid take value from combobox in vb6






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















I'm working on this payroll system for a company but somehow whenever I change the employee ID in the ComboBox it wont display the employee information on the labels.



I've tried changing the syntax of the query but still nothing



Dim cbo_id As New CAutoCompleteComboBox
Dim rs As New ADODB.Recordset

Private Sub cboEmpID_Change()

On Error GoTo err:

If Me.cboEmpID.Text = vbNullString Then Exit Sub

If rs.State = adStateOpen Then rs.Close

rs.Open "Select * from tblEmp where EM_ID = ' & cboEmpID.Text & '", cn, adOpenKeyset, adLockPessimistic

Do While rs.EOF = True
Me.lblName.Caption = " " & rs.Fields("NAME").Value
Me.lblDept.Caption = " " & rs.Fields("DEPT").Value
Me.lblPosition.Caption = " " & rs.Fields("POSITION").Value
Me.lblRate.Caption = FormatNumber(CCur(rs.Fields("Basic_Rate").Value), 2)
Me.lblStatus.Caption = " " & rs.Fields("Emp_Stat").Value
Me.lblPerDay.Caption = FormatNumber(CCur(Me.lblRate.Caption / 30), 2)
Me.lblNetPay.Caption = FormatNumber(CCur(Me.lblRate.Caption), 2)
rs.MoveNext
Loop

Exit Sub

err:
MsgBox err.Description, vbCritical, "Error"
Set rs = Nothing
End Sub









share|improve this question



















  • 6





    I know nothing about recordsets, but the line Do While rs.EOF = True looks wrong. Maybe Do Until?

    – Jim Mack
    Mar 25 at 3:10

















2















I'm working on this payroll system for a company but somehow whenever I change the employee ID in the ComboBox it wont display the employee information on the labels.



I've tried changing the syntax of the query but still nothing



Dim cbo_id As New CAutoCompleteComboBox
Dim rs As New ADODB.Recordset

Private Sub cboEmpID_Change()

On Error GoTo err:

If Me.cboEmpID.Text = vbNullString Then Exit Sub

If rs.State = adStateOpen Then rs.Close

rs.Open "Select * from tblEmp where EM_ID = ' & cboEmpID.Text & '", cn, adOpenKeyset, adLockPessimistic

Do While rs.EOF = True
Me.lblName.Caption = " " & rs.Fields("NAME").Value
Me.lblDept.Caption = " " & rs.Fields("DEPT").Value
Me.lblPosition.Caption = " " & rs.Fields("POSITION").Value
Me.lblRate.Caption = FormatNumber(CCur(rs.Fields("Basic_Rate").Value), 2)
Me.lblStatus.Caption = " " & rs.Fields("Emp_Stat").Value
Me.lblPerDay.Caption = FormatNumber(CCur(Me.lblRate.Caption / 30), 2)
Me.lblNetPay.Caption = FormatNumber(CCur(Me.lblRate.Caption), 2)
rs.MoveNext
Loop

Exit Sub

err:
MsgBox err.Description, vbCritical, "Error"
Set rs = Nothing
End Sub









share|improve this question



















  • 6





    I know nothing about recordsets, but the line Do While rs.EOF = True looks wrong. Maybe Do Until?

    – Jim Mack
    Mar 25 at 3:10













2












2








2








I'm working on this payroll system for a company but somehow whenever I change the employee ID in the ComboBox it wont display the employee information on the labels.



I've tried changing the syntax of the query but still nothing



Dim cbo_id As New CAutoCompleteComboBox
Dim rs As New ADODB.Recordset

Private Sub cboEmpID_Change()

On Error GoTo err:

If Me.cboEmpID.Text = vbNullString Then Exit Sub

If rs.State = adStateOpen Then rs.Close

rs.Open "Select * from tblEmp where EM_ID = ' & cboEmpID.Text & '", cn, adOpenKeyset, adLockPessimistic

Do While rs.EOF = True
Me.lblName.Caption = " " & rs.Fields("NAME").Value
Me.lblDept.Caption = " " & rs.Fields("DEPT").Value
Me.lblPosition.Caption = " " & rs.Fields("POSITION").Value
Me.lblRate.Caption = FormatNumber(CCur(rs.Fields("Basic_Rate").Value), 2)
Me.lblStatus.Caption = " " & rs.Fields("Emp_Stat").Value
Me.lblPerDay.Caption = FormatNumber(CCur(Me.lblRate.Caption / 30), 2)
Me.lblNetPay.Caption = FormatNumber(CCur(Me.lblRate.Caption), 2)
rs.MoveNext
Loop

Exit Sub

err:
MsgBox err.Description, vbCritical, "Error"
Set rs = Nothing
End Sub









share|improve this question
















I'm working on this payroll system for a company but somehow whenever I change the employee ID in the ComboBox it wont display the employee information on the labels.



I've tried changing the syntax of the query but still nothing



Dim cbo_id As New CAutoCompleteComboBox
Dim rs As New ADODB.Recordset

Private Sub cboEmpID_Change()

On Error GoTo err:

If Me.cboEmpID.Text = vbNullString Then Exit Sub

If rs.State = adStateOpen Then rs.Close

rs.Open "Select * from tblEmp where EM_ID = ' & cboEmpID.Text & '", cn, adOpenKeyset, adLockPessimistic

Do While rs.EOF = True
Me.lblName.Caption = " " & rs.Fields("NAME").Value
Me.lblDept.Caption = " " & rs.Fields("DEPT").Value
Me.lblPosition.Caption = " " & rs.Fields("POSITION").Value
Me.lblRate.Caption = FormatNumber(CCur(rs.Fields("Basic_Rate").Value), 2)
Me.lblStatus.Caption = " " & rs.Fields("Emp_Stat").Value
Me.lblPerDay.Caption = FormatNumber(CCur(Me.lblRate.Caption / 30), 2)
Me.lblNetPay.Caption = FormatNumber(CCur(Me.lblRate.Caption), 2)
rs.MoveNext
Loop

Exit Sub

err:
MsgBox err.Description, vbCritical, "Error"
Set rs = Nothing
End Sub






vb6






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 11:38









DaveInCaz

3,87532244




3,87532244










asked Mar 25 at 2:40









Earlmond Ross LeeEarlmond Ross Lee

111




111







  • 6





    I know nothing about recordsets, but the line Do While rs.EOF = True looks wrong. Maybe Do Until?

    – Jim Mack
    Mar 25 at 3:10












  • 6





    I know nothing about recordsets, but the line Do While rs.EOF = True looks wrong. Maybe Do Until?

    – Jim Mack
    Mar 25 at 3:10







6




6





I know nothing about recordsets, but the line Do While rs.EOF = True looks wrong. Maybe Do Until?

– Jim Mack
Mar 25 at 3:10





I know nothing about recordsets, but the line Do While rs.EOF = True looks wrong. Maybe Do Until?

– Jim Mack
Mar 25 at 3:10












1 Answer
1






active

oldest

votes


















0














Looking at your code I think that you are only expecting one row of data back from your request, so just code an If to check that a row was returned. I don't have VB6 any more but this code should do the job:



Private Sub cboEmpID_Change()
On Error GoTo err:
If Me.cboEmpID.Text = vbNullString Then Exit Sub

If rs.State = adStateOpen Then rs.Close

rs.Open "Select * from tblEmp where EM_ID = ' & cboEmpID.Text & '", cn, adOpenKeyset, adLockPessimistic

If rs.EOF = False Then
Me.lblName.Caption = " " & rs.Fields("NAME").Value
Me.lblDept.Caption = " " & rs.Fields("DEPT").Value
Me.lblPosition.Caption = " " & rs.Fields("POSITION").Value
Me.lblRate.Caption = FormatNumber(CCur(rs.Fields("Basic_Rate").Value), 2)
Me.lblStatus.Caption = " " & rs.Fields("Emp_Stat").Value
Me.lblPerDay.Caption = FormatNumber(CCur(Me.lblRate.Caption / 30), 2)
Me.lblNetPay.Caption = FormatNumber(CCur(Me.lblRate.Caption), 2)
End If

Exit Sub

err:
MsgBox err.Description, vbCritical, "Error"
Set rs = Nothing
End Sub





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330611%2fvalues-wont-show-to-labels-when-i-change-the-combobox-data-value%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Looking at your code I think that you are only expecting one row of data back from your request, so just code an If to check that a row was returned. I don't have VB6 any more but this code should do the job:



    Private Sub cboEmpID_Change()
    On Error GoTo err:
    If Me.cboEmpID.Text = vbNullString Then Exit Sub

    If rs.State = adStateOpen Then rs.Close

    rs.Open "Select * from tblEmp where EM_ID = ' & cboEmpID.Text & '", cn, adOpenKeyset, adLockPessimistic

    If rs.EOF = False Then
    Me.lblName.Caption = " " & rs.Fields("NAME").Value
    Me.lblDept.Caption = " " & rs.Fields("DEPT").Value
    Me.lblPosition.Caption = " " & rs.Fields("POSITION").Value
    Me.lblRate.Caption = FormatNumber(CCur(rs.Fields("Basic_Rate").Value), 2)
    Me.lblStatus.Caption = " " & rs.Fields("Emp_Stat").Value
    Me.lblPerDay.Caption = FormatNumber(CCur(Me.lblRate.Caption / 30), 2)
    Me.lblNetPay.Caption = FormatNumber(CCur(Me.lblRate.Caption), 2)
    End If

    Exit Sub

    err:
    MsgBox err.Description, vbCritical, "Error"
    Set rs = Nothing
    End Sub





    share|improve this answer



























      0














      Looking at your code I think that you are only expecting one row of data back from your request, so just code an If to check that a row was returned. I don't have VB6 any more but this code should do the job:



      Private Sub cboEmpID_Change()
      On Error GoTo err:
      If Me.cboEmpID.Text = vbNullString Then Exit Sub

      If rs.State = adStateOpen Then rs.Close

      rs.Open "Select * from tblEmp where EM_ID = ' & cboEmpID.Text & '", cn, adOpenKeyset, adLockPessimistic

      If rs.EOF = False Then
      Me.lblName.Caption = " " & rs.Fields("NAME").Value
      Me.lblDept.Caption = " " & rs.Fields("DEPT").Value
      Me.lblPosition.Caption = " " & rs.Fields("POSITION").Value
      Me.lblRate.Caption = FormatNumber(CCur(rs.Fields("Basic_Rate").Value), 2)
      Me.lblStatus.Caption = " " & rs.Fields("Emp_Stat").Value
      Me.lblPerDay.Caption = FormatNumber(CCur(Me.lblRate.Caption / 30), 2)
      Me.lblNetPay.Caption = FormatNumber(CCur(Me.lblRate.Caption), 2)
      End If

      Exit Sub

      err:
      MsgBox err.Description, vbCritical, "Error"
      Set rs = Nothing
      End Sub





      share|improve this answer

























        0












        0








        0







        Looking at your code I think that you are only expecting one row of data back from your request, so just code an If to check that a row was returned. I don't have VB6 any more but this code should do the job:



        Private Sub cboEmpID_Change()
        On Error GoTo err:
        If Me.cboEmpID.Text = vbNullString Then Exit Sub

        If rs.State = adStateOpen Then rs.Close

        rs.Open "Select * from tblEmp where EM_ID = ' & cboEmpID.Text & '", cn, adOpenKeyset, adLockPessimistic

        If rs.EOF = False Then
        Me.lblName.Caption = " " & rs.Fields("NAME").Value
        Me.lblDept.Caption = " " & rs.Fields("DEPT").Value
        Me.lblPosition.Caption = " " & rs.Fields("POSITION").Value
        Me.lblRate.Caption = FormatNumber(CCur(rs.Fields("Basic_Rate").Value), 2)
        Me.lblStatus.Caption = " " & rs.Fields("Emp_Stat").Value
        Me.lblPerDay.Caption = FormatNumber(CCur(Me.lblRate.Caption / 30), 2)
        Me.lblNetPay.Caption = FormatNumber(CCur(Me.lblRate.Caption), 2)
        End If

        Exit Sub

        err:
        MsgBox err.Description, vbCritical, "Error"
        Set rs = Nothing
        End Sub





        share|improve this answer













        Looking at your code I think that you are only expecting one row of data back from your request, so just code an If to check that a row was returned. I don't have VB6 any more but this code should do the job:



        Private Sub cboEmpID_Change()
        On Error GoTo err:
        If Me.cboEmpID.Text = vbNullString Then Exit Sub

        If rs.State = adStateOpen Then rs.Close

        rs.Open "Select * from tblEmp where EM_ID = ' & cboEmpID.Text & '", cn, adOpenKeyset, adLockPessimistic

        If rs.EOF = False Then
        Me.lblName.Caption = " " & rs.Fields("NAME").Value
        Me.lblDept.Caption = " " & rs.Fields("DEPT").Value
        Me.lblPosition.Caption = " " & rs.Fields("POSITION").Value
        Me.lblRate.Caption = FormatNumber(CCur(rs.Fields("Basic_Rate").Value), 2)
        Me.lblStatus.Caption = " " & rs.Fields("Emp_Stat").Value
        Me.lblPerDay.Caption = FormatNumber(CCur(Me.lblRate.Caption / 30), 2)
        Me.lblNetPay.Caption = FormatNumber(CCur(Me.lblRate.Caption), 2)
        End If

        Exit Sub

        err:
        MsgBox err.Description, vbCritical, "Error"
        Set rs = Nothing
        End Sub






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 18:28









        OldBoyCoderOldBoyCoder

        808516




        808516



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330611%2fvalues-wont-show-to-labels-when-i-change-the-combobox-data-value%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현