[TEX][B][U]form1[/U][/B][/TEX]
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim cmd As New ADODB.Command
Dim adrs As New ADODB.Recordset
Private Sub Command1_Click()
cmd.CommandText = "insert into table1 values('" & Text1.Text & "','" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Combo1.Text & "','" & Text5.Text & "','" & Text6.Text & "','" & Text7.Text & "','" & Text8.Text & "')"
cmd.Execute
MsgBox "record inserted"
End Sub
Private Sub Calendar1_afterudate()
Calendar1.Visible = False
Text7.Text = Calendar1.Day & "/" & Calendar1.Month & "/" & Calendar1.Year
Calendar1.Visible = False
Calendar2.Visible = True
End Sub
Private Sub Calendar2_afterudate()
Calendar2.Visible = False
Text7.Text = Calendar2.Day & "/" & Calendar2.Month & "/" & Calendar2.Year
Calendar2.Visible = False
End Sub
Private Sub Command2_Click()
Form2.Text1.Text = Text1.Text
Form2.Text2.Text = Text2.Text
Form2.Text3.Text = Text5.Text
Form2.Show
End Sub
Private Sub Form_Load()
Calendar1.Visible = True
Calendar2.Visible = False
Combo1.AddItem ("Male")
Combo1.AddItem ("Female")
Set cn = New ADODB.Connection
[U][B]cn.Open "provider=MSDASQL.1;persist security info=true; data source=ADODB"
[/B][/U]Set rs = New ADODB.Recordset
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic
rs.Open "select * from table1", cn
adrs.Open "select max(eid)+1 from table1", cn
If rs.BOF And rs.EOF Then
Text1.Text = "10001"
Else
Text1.Text = adrs.Fields(0)
End If
Set cmd = New ADODB.Command
cmd.ActiveConnection = cn
MsgBox "Well Connected"
End Sub
Public Sub clear()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Combo1.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
End Sub
Public Sub disp()
Text1.Text = rs(0)
Text2.Text = rs(1)
Text3.Text = rs(2)
Text4.Text = rs(3)
Combo1.Text = rs(4)
Text5.Text = rs(5)
Text6.Text = rs(6)
Text7.Text = rs(7)
Text8.Text = rs(8)
End Sub
Private Sub Text4_GotFocus()
Calendar1.Visible = True
End Sub
Private Sub Text6_GotFocus()
Calendar2.Visible = True
End Sub
form2
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim cmd As New ADODB.Command
Private Sub Command1_Click()
Text10.Text = Val(Text4.Text) * 12 / 100
Text11.Text = Val(Text4.Text) + Val(Text10.Text) + Val(Text6.Text) + Val(Text5.Text) + Val(Text8.Text)
Text12.Text = Val(Text11.Text) - Val(Text7.Text) + Val(Text9.Text) * 2 / 100
cmd.CommandText = "insert into table2 values('" & Text1.Text & "','" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "','" & Text6.Text & "','" & Text7.Text & "','" & Text8.Text & "','" & Text9.Text & "','" & Text10.Text & "','" & Text11.Text & "','" & Text12.Text & "')"
cmd.Execute
MsgBox "Details Inserted"
End Sub
Private Sub Command2_Click()
dataenvironment1.rscommand1.Open "select * from table2 where eid=" & Form1.Text1.Text & ""
datareport1.Show
End Sub
Private Sub Form_Load()
Set cn = New ADODB.Connection
cn.Open "provider=MSDASQL.1;persist security info=true;data source=itspayroll"
Set rs = New ADODB.Recordset
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic
rs.Open "select * from table2", cn
Set cmd = New ADODB.Command
cmd.ActiveConnection = cn
MsgBox "Well Connected"
End Sub
Public Sub clear()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
End Sub
Public Sub disp()
Text1.Text = rs(0)
Text2.Text = rs(1)
Text3.Text = rs(2)
Text4.Text = rs(3)
Text5.Text = rs(4)
Text6.Text = rs(5)
Text7.Text = rs(6)
Text8.Text = rs(7)
Text9.Text = rs(8)
Text10.Text = rs(9)
Text11.Text = rs(10)
Text12.Text = rs(11)
Text13.Text = rs(12)
End Sub