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;
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
add a comment |
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
6
I know nothing about recordsets, but the lineDo While rs.EOF = True
looks wrong. MaybeDo Until
?
– Jim Mack
Mar 25 at 3:10
add a comment |
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
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
vb6
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 lineDo While rs.EOF = True
looks wrong. MaybeDo Until
?
– Jim Mack
Mar 25 at 3:10
add a comment |
6
I know nothing about recordsets, but the lineDo While rs.EOF = True
looks wrong. MaybeDo 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
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
answered Mar 25 at 18:28
OldBoyCoderOldBoyCoder
808516
808516
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
6
I know nothing about recordsets, but the line
Do While rs.EOF = True
looks wrong. MaybeDo Until
?– Jim Mack
Mar 25 at 3:10