|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
hi
i want to save the records from two tables into third table.now the problem is that when i click the save button in third table then first record of first table is saved twice with first and second record of second table.the code is shown below Public rs As New ADODB.Recordset Public rs1 As New ADODB.Recordset Public rs2 As New ADODB.Recordset Public cn As New ADODB.Connection Public STR As String Public a As String Dim t As String Dim d As Date Private Sub cmdsave_Click() Command1.Enabled = True If rs2.State = adStateOpen Then rs2.Close rs2.Open "select * from table2", cn, adOpenKeyset, adLockOptimistic rs2.AddNew rs2!trouble_ticket_no = txtno.Text rs2!fault_time = txtfault.Text MsgBox ("entries have been saved") rs2.Update If rs1.State = adStateOpen Then rs1.Close rs1.Open "select * from table1", cn, adOpenKeyset, adLockOptimistic If rs2.State = adStateOpen Then rs2.Close rs2.Open "select * from table2", cn, adOpenKeyset, adLockOptimistic If rs.State = adStateOpen Then rs.Close rs.Open "select * from table3", cn, adOpenKeyset, adLockOptimistic If rs1.BOF = True And rs2.BOF = True Then rs!Date1 = rs1!Date1 rs!customer_name = rs1!customer_name rs!reported_to = rs1!reported_to rs!reported_by = rs1!reported_by rs!description_of_fault = rs1!description_of_fault rs!trouble_ticket_no = rs2!trouble_ticket_noH rs!fault_time = rs2!fault_time rs!Update = rs2!Update rs2.MoveNext rs1.MoveNext rs.Update Else rs2.MoveLast rs1.MoveLast rs.AddNew rs!Date1 = rs1!Date1 rs!customer_name = rs1!customer_name rs!reported_to = rs1!reported_to rs!reported_by = rs1!reported_by rs!description_of_fault = rs1!description_of_fault rs!trouble_ticket_no = rs2!trouble_ticket_no rs!fault_time = rs2!fault_time rs!Update = rs2!Update rs.Update End If End Sub |
|
#2
|
||||
|
||||
|
try this (I think) if the tables has 3 fields (FieldNum, FieldTxt and FieldTxt2):
Quote:
... or ... Quote:
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > i m looking for someone who can solve my vb problem quickly???????? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
![]() |
|