09-03-2012, 11:49 PM
Please help!!! i have been creating a project based on vb6.0 and Mysql 5.51 as database.. i have created 36 tables out of this there is a one which can be called a master table and the left 35 tables are branch tables so i want to store data in master table and in branch tables as mention in the master tables so please help me out into this!! the code before this is -:
Private Sub cmdClear_Click()
Call ClearTextBoxes(Me)
End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdSave_Click()
Dim x As Date
x = CDate(Me.txtDate.Text = " yyyy-mm-dd ")
If Me.txtStartno.Text = "" Then
MsgBox "Please fill up the field!!"
Me.txtStartno.SetFocus
Exit Sub
End If
If Me.txtEndno.Text = "" Then
MsgBox "Please fill up the field!!"
Me.txtEndno.SetFocus
Exit Sub
End If
If Me.txtDate.Text = "" Then
MsgBox "Please fill up the field!!"
Me.txtDate.SetFocus
Exit Sub
End If
If Me.txtBrncode.Text = "" Then
MsgBox "Please fill up the field!!"
Me.txtBrncode.SetFocus
Exit Sub
End If
With Adodc1
.CommandType = adCmdText
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields(0) = Me.txtStartno.Text
Adodc1.Recordset.Fields(1) = Me.txtEndno.Text
Adodc1.Recordset.Fields(2) = x
Adodc1.Recordset.Fields(3) = Me.txtBrncode.Text
Adodc1.Recordset.Update
Adodc1.Refresh
DataGrid1.Refresh
MsgBox "Successfully added!"
End With
End Sub
Private Sub cmdSearch_Click()
Dim pcnl As ADODB.Connection
Dim rs As ADODB.Recordset
'Create a new instance of connection and recordset
Set pcnl = New ADODB.Connection
Set rs = New ADODB.Recordset
'Open connection
pcnl.Open " Provider=MSDASQL.1;Persist Security Info=False;User ID=root;Data Source=MYSQL;Mode=Read;Initial
Catalog=missing"
'Open recordset
Dim strSql As String
strSql = "SELECT * FROM Issue_Tab WHERE Startno LIKE " & "'" & txtSearch.Text & "'"
rs.Open strSql, pcnl, adOpenStatic, adLockOptimistic
'See if any records exist. If not exit sub and close connection and
'recordset. If yes, display data in text boxes
If rs.BOF = True Or rs.EOF = True Then
MsgBox "No records exist"
rs.Close
pcnl.Close
Exit Sub
Else
txtStartno.Text = rs!Startno
txtEndno.Text = rs!Endno
txtDate.Text = rs!Issuedate
txtBrncode.Text = rs!Brncode
rs.Close
pcnl.Close
End If
End Sub
Private Sub cmdShow_Click()
Adodc1.RecordSource = " select * from Issue_Tab "
Adodc1.Refresh
End Sub
Private Sub cmdUpdate_Click()
Adodc1.Recordset.Update
Adodc1.Refresh
Adodc1.Recordset("Startno").Value = Me.txtStartno.Text
Adodc1.Recordset("Endno").Value = Me.txtEndno.Text
Adodc1.Recordset("Issuedate").Value = Me.txtDate.Text
Adodc1.Recordset("Brncode").Value = Me.txtBrncode.Text
End Sub
Private Sub DataGrid1_AfterDelete()
MsgBox " Record Deleted!!! "
End Sub
Private Sub DataGrid1_AfterInsert()
MsgBox " Record is added"
End Sub
Private Sub DataGrid1_AfterUpdate()
MsgBox " Record Updated!!! "
End Sub
so please help me out