Octopus Posted August 13, 2004 Share Posted August 13, 2004 I have 2 tables, I cant do it,,I always get an error could you please help? here is the code.......I attached the source too [/code] Private Sub cmdClear_Click() For Each ctl In Controls If TypeOf ctl Is TextBox Then ctl.Text = "" Next ctl txtempno.SetFocus End Sub Private Sub cmdFind_Click() 'On Error GoTo ErrorMsg DE1.rsemp.Open "select * from Employee" & _ " where empno = " & txtempno.Text & "" If Not DE1.rsemp.BOF And Not DE1.rsemp.EOF Then txtFirstName = DE1.rsemp("FirstName") txtFamilyName = DE1.rsemp("FamilyName") txtSalary.Text = DE1.rsemp("Salary") txtHireDate.Text = DE1.rsemp("HireDate") txtJob.Text = DE1.rsemp("Job") txtCommission.Text = DE1.rsemp("Comm") txtDeptNo.Text = DE1.rsemp("Deptno") Else MsgBox "Not Found", vbExclamation End If 'ErrorMsg: 'MsgBox "Error 1" 'MsgBox Err.Description DE1.rsemp.Close End Sub Private Sub cmdUpdate_Click() On Error GoTo MsgErr DE1.rsemp.Open " Select * From Employee " & _ " where empid = " & txtempno.Text & "" If DE1.rsemp.RecordCount > 0 Then UpdateRec Else End If DE1.rsemp.Close MsgErr: MsgBox " Error 001" MsgBox Err.Description End Sub Private Sub UpdateRec() DE1.conn.Execute " Update Employee Set " & _ "Salary = " & txtSalary.Text End Sub Private Sub Command1_Click() Dim rsemp As New ADODB.Recordset If DE1.rslib.State <> adStateClose Then DE1.rslib.Close DE1.rslib.Open "Select * From BooksIssue where empno = " & txtempno.Text & "" Set H_Grid.DataSource = DE1.rslib DE1.rslib.Close End Sub Private Sub PK() 'On Error GoTo Msg1 DE1.rslib.Open " select * from BooksIssue " & _ " where BookId = '" & txtPK.Text & "'" If Not DE1.rslib.BOF And Not DE1.rslib.EOF Then txtBookId.Text = DE1.rslib("BookId") txtempno2.Text = DE1.rslib("Empno") txtIssueDate.Text = DE1.rslib("IssueDate") txtDueDate.Text = DE1.rslib("DueDate") Else MsgBox "Not avaiable,please choose from BookId column", vbExclamation End If 'Msg1: 'MsgBox "Choose from BookId column please" DE1.rslib.Close End Sub Private Sub Command2_Click() DR1.Show End Sub Private Sub H_Grid_Click() txtPK.Text = H_Grid.Text PK End Sub code.zip Link to comment Share on other sites More sharing options...
0 +John Teacake MVC Posted August 13, 2004 MVC Share Posted August 13, 2004 Thats Easy. Where you have your error handling you need exit sub before it. Ive fixed it. Try that. Private Sub cmdClear_Click() For Each ctl In Controls If TypeOf ctl Is TextBox Then ctl.Text = "" Next ctl txtempno.SetFocus End Sub Private Sub cmdFind_Click() 'On Error GoTo ErrorMsg DE1.rsemp.Open "select * from Employee" & _ " where empno = " & txtempno.Text & "" If Not DE1.rsemp.BOF And Not DE1.rsemp.EOF Then txtFirstName = DE1.rsemp("FirstName") txtFamilyName = DE1.rsemp("FamilyName") txtSalary.Text = DE1.rsemp("Salary") txtHireDate.Text = DE1.rsemp("HireDate") txtJob.Text = DE1.rsemp("Job") txtCommission.Text = DE1.rsemp("Comm") txtDeptNo.Text = DE1.rsemp("Deptno") Else MsgBox "Not Found", vbExclamation End If 'ErrorMsg: 'MsgBox "Error 1" 'MsgBox Err.Description DE1.rsemp.Close End Sub Private Sub cmdUpdate_Click() On Error GoTo MsgErr DE1.rsemp.Open " Select * From Employee " & _ " where empid = " & txtempno.Text & "" If DE1.rsemp.RecordCount > 0 Then UpdateRec Else End If DE1.rsemp.Close MsgErr: MsgBox " Error 001" MsgBox Err.Description End Sub Private Sub UpdateRec() DE1.conn.Execute " Update Employee Set " & _ "Salary = " & txtSalary.Text End Sub Private Sub Command1_Click() Dim rsemp As New ADODB.Recordset If DE1.rslib.State <> adStateClose Then DE1.rslib.Close DE1.rslib.Open "Select * From BooksIssue where empno = " & txtempno.Text & "" Set H_Grid.DataSource = DE1.rslib DE1.rslib.Close End Sub Private Sub PK() 'On Error GoTo Msg1 DE1.rslib.Open " select * from BooksIssue " & _ " where BookId = '" & txtPK.Text & "'" If Not DE1.rslib.BOF And Not DE1.rslib.EOF Then txtBookId.Text = DE1.rslib("BookId") txtempno2.Text = DE1.rslib("Empno") txtIssueDate.Text = DE1.rslib("IssueDate") txtDueDate.Text = DE1.rslib("DueDate") Else MsgBox "Not avaiable,please choose from BookId column", vbExclamation End If Exit Sub 'Msg1: 'MsgBox "Choose from BookId column please" DE1.rslib.Close End Sub Private Sub Command2_Click() DR1.Show End Sub Private Sub H_Grid_Click() txtPK.Text = H_Grid.Text PK End Sub Link to comment Share on other sites More sharing options...
0 Octopus Posted August 14, 2004 Author Share Posted August 14, 2004 no...did you take a look at the attached file? I want to update and inser records through it into MS Access database file. I get errors in the query...if someone could help me with ypdate insert queries please? Link to comment Share on other sites More sharing options...
0 +John Teacake MVC Posted August 14, 2004 MVC Share Posted August 14, 2004 Ok but what I did was fix another problem you would have. Link to comment Share on other sites More sharing options...
Question
Octopus
I have 2 tables, I cant do it,,I always get an error could you please help?
here is the code.......I attached the source too
[/code]
Private Sub cmdClear_Click()
For Each ctl In Controls
If TypeOf ctl Is TextBox Then ctl.Text = ""
Next ctl
txtempno.SetFocus
End Sub
Private Sub cmdFind_Click()
'On Error GoTo ErrorMsg
DE1.rsemp.Open "select * from Employee" & _
" where empno = " & txtempno.Text & ""
If Not DE1.rsemp.BOF And Not DE1.rsemp.EOF Then
txtFirstName = DE1.rsemp("FirstName")
txtFamilyName = DE1.rsemp("FamilyName")
txtSalary.Text = DE1.rsemp("Salary")
txtHireDate.Text = DE1.rsemp("HireDate")
txtJob.Text = DE1.rsemp("Job")
txtCommission.Text = DE1.rsemp("Comm")
txtDeptNo.Text = DE1.rsemp("Deptno")
Else
MsgBox "Not Found", vbExclamation
End If
'ErrorMsg:
'MsgBox "Error 1"
'MsgBox Err.Description
DE1.rsemp.Close
End Sub
Private Sub cmdUpdate_Click()
On Error GoTo MsgErr
DE1.rsemp.Open " Select * From Employee " & _
" where empid = " & txtempno.Text & ""
If DE1.rsemp.RecordCount > 0 Then
UpdateRec
Else
End If
DE1.rsemp.Close
MsgErr:
MsgBox " Error 001"
MsgBox Err.Description
End Sub
Private Sub UpdateRec()
DE1.conn.Execute " Update Employee Set " & _
"Salary = " & txtSalary.Text
End Sub
Private Sub Command1_Click()
Dim rsemp As New ADODB.Recordset
If DE1.rslib.State <> adStateClose Then DE1.rslib.Close
DE1.rslib.Open "Select * From BooksIssue where empno = " & txtempno.Text & ""
Set H_Grid.DataSource = DE1.rslib
DE1.rslib.Close
End Sub
Private Sub PK()
'On Error GoTo Msg1
DE1.rslib.Open " select * from BooksIssue " & _
" where BookId = '" & txtPK.Text & "'"
If Not DE1.rslib.BOF And Not DE1.rslib.EOF Then
txtBookId.Text = DE1.rslib("BookId")
txtempno2.Text = DE1.rslib("Empno")
txtIssueDate.Text = DE1.rslib("IssueDate")
txtDueDate.Text = DE1.rslib("DueDate")
Else
MsgBox "Not avaiable,please choose from BookId column", vbExclamation
End If
'Msg1:
'MsgBox "Choose from BookId column please"
DE1.rslib.Close
End Sub
Private Sub Command2_Click()
DR1.Show
End Sub
Private Sub H_Grid_Click()
txtPK.Text = H_Grid.Text
PK
End Sub
code.zip
Link to comment
Share on other sites
3 answers to this question
Recommended Posts