Hi...
Below is my code:
[code=vb]Dim trs As New ADODB.Recordset
Public cn As ADODB.Connectio n
Public Sub databaseconnect ()
Set cn = New ADODB.Connectio n
cn.Open "Provider=SQLOL EDB.1;Integrate d Security=SSPI;P ersist Security Info=False;Init ial Catalog=hrms;Da ta Source=."
End Sub
Private Sub Combo1_Click() ' pcode
Do While MSFlexGrid1.Row s > 1
MSFlexGrid1.Rem oveItem (MSFlexGrid1.Ro ws)
Loop
If Combo1 <> "" Then
trs.Open "select * from prjmaster where pcode = '" & Combo1 & "'", cn
Label7 = trs.Fields(1)
trs.Close
End If
trs.Open "select empid from prjtrans where pcode='" & Combo1 & "'", cn
Dim ers As Recordset
Do While Not trs.EOF
If trs.RecordCount > 0 Then
ers.Open "select empname from empmaster where empid= " & trs.Fields(0), cn
MSFlexGrid1.Add Item ("")
MSFlexGrid1.Col = 1
MSFlexGrid1.Row = MSFlexGrid1.Row s - 1
MSFlexGrid1.Tex t = trs.Fields(0)
MSFlexGrid1.Col = 2
MSFlexGrid1.Tex t =ers.Fields(1)
End If
trs.MoveNext
Loop
trs.Close
End Sub
Private Sub Combo2_Click() 'empid
If Combo1 <> "" Then
trs.Open "select * from empmaster where empid = " & Combo2, cn
Label9 = trs.Fields(1)
trs.Close
End If
End Sub
Private Sub Command1_Click( ) 'ADD BUTTON
trs.Open "select pcode from prjtrans where pcode = '" + pcode + "'" + "and empid =" + Combo2, cn
cn.Execute "insert into prjtrans values('" & Combo1 & "'," & Combo2 & ",'" & DTPicker1.Value & "','" & DTPicker2.Value & "','" & Combo3.Text & "')"
MSFlexGrid1.Add Item ("")
MSFlexGrid1.Col = 1
MSFlexGrid1.Row = MSFlexGrid1.Row s - 1
MSFlexGrid1.Tex t = Combo2.Text
MSFlexGrid1.Col = 2
MSFlexGrid1.Tex t = Label9
trs.Close
End Sub
Private Sub Form_Load()
Call databaseconnect
trs.Open "select * from prjmaster", cn
Do While Not trs.EOF
Combo1.AddItem trs.Fields(0)
trs.MoveNext
Loop
trs.Close
trs.Open "select * from empmaster", cn
Do While Not trs.EOF
Combo2.AddItem trs.Fields(0)
trs.MoveNext
Loop
trs.Close
Combo3.AddItem "Group Leader"
Combo3.AddItem "Group Member"
MSFlexGrid1.Col Width(0) = 0
MSFlexGrid1.Col Width(2) = 1800
MSFlexGrid1.Col = 1
MSFlexGrid1.Row = 0
MSFlexGrid1.Tex t = "Emp ID"
MSFlexGrid1.Col = 2
MSFlexGrid1.Row = 0
MSFlexGrid1.Tex t = "Name"
End Sub[/code]
My problem is... the values inserted in the prjtrans table... cant get viewable in the flexgrid control while clicking the combo1...
By clicking command1... at tht time...the inserted value gets displayed in the flexgrid...
i cant able to retrieve..from prjtrans...to show in flexgrid while clicking combo1...
Pl...help me...
Sree,
Below is my code:
[code=vb]Dim trs As New ADODB.Recordset
Public cn As ADODB.Connectio n
Public Sub databaseconnect ()
Set cn = New ADODB.Connectio n
cn.Open "Provider=SQLOL EDB.1;Integrate d Security=SSPI;P ersist Security Info=False;Init ial Catalog=hrms;Da ta Source=."
End Sub
Private Sub Combo1_Click() ' pcode
Do While MSFlexGrid1.Row s > 1
MSFlexGrid1.Rem oveItem (MSFlexGrid1.Ro ws)
Loop
If Combo1 <> "" Then
trs.Open "select * from prjmaster where pcode = '" & Combo1 & "'", cn
Label7 = trs.Fields(1)
trs.Close
End If
trs.Open "select empid from prjtrans where pcode='" & Combo1 & "'", cn
Dim ers As Recordset
Do While Not trs.EOF
If trs.RecordCount > 0 Then
ers.Open "select empname from empmaster where empid= " & trs.Fields(0), cn
MSFlexGrid1.Add Item ("")
MSFlexGrid1.Col = 1
MSFlexGrid1.Row = MSFlexGrid1.Row s - 1
MSFlexGrid1.Tex t = trs.Fields(0)
MSFlexGrid1.Col = 2
MSFlexGrid1.Tex t =ers.Fields(1)
End If
trs.MoveNext
Loop
trs.Close
End Sub
Private Sub Combo2_Click() 'empid
If Combo1 <> "" Then
trs.Open "select * from empmaster where empid = " & Combo2, cn
Label9 = trs.Fields(1)
trs.Close
End If
End Sub
Private Sub Command1_Click( ) 'ADD BUTTON
trs.Open "select pcode from prjtrans where pcode = '" + pcode + "'" + "and empid =" + Combo2, cn
cn.Execute "insert into prjtrans values('" & Combo1 & "'," & Combo2 & ",'" & DTPicker1.Value & "','" & DTPicker2.Value & "','" & Combo3.Text & "')"
MSFlexGrid1.Add Item ("")
MSFlexGrid1.Col = 1
MSFlexGrid1.Row = MSFlexGrid1.Row s - 1
MSFlexGrid1.Tex t = Combo2.Text
MSFlexGrid1.Col = 2
MSFlexGrid1.Tex t = Label9
trs.Close
End Sub
Private Sub Form_Load()
Call databaseconnect
trs.Open "select * from prjmaster", cn
Do While Not trs.EOF
Combo1.AddItem trs.Fields(0)
trs.MoveNext
Loop
trs.Close
trs.Open "select * from empmaster", cn
Do While Not trs.EOF
Combo2.AddItem trs.Fields(0)
trs.MoveNext
Loop
trs.Close
Combo3.AddItem "Group Leader"
Combo3.AddItem "Group Member"
MSFlexGrid1.Col Width(0) = 0
MSFlexGrid1.Col Width(2) = 1800
MSFlexGrid1.Col = 1
MSFlexGrid1.Row = 0
MSFlexGrid1.Tex t = "Emp ID"
MSFlexGrid1.Col = 2
MSFlexGrid1.Row = 0
MSFlexGrid1.Tex t = "Name"
End Sub[/code]
My problem is... the values inserted in the prjtrans table... cant get viewable in the flexgrid control while clicking the combo1...
By clicking command1... at tht time...the inserted value gets displayed in the flexgrid...
i cant able to retrieve..from prjtrans...to show in flexgrid while clicking combo1...
Pl...help me...
Sree,
Comment