I've got 2 flex grids in one VB form and I wanna connect both of these Flex Grids to 2 different tables in MS Access.
This is how my form looks like:
http://i213.photobucket.com/albums/cc228/rose_408/form_zps100c290c.png
Here's the code for the service flex grid (FlexService):
Private Sub Form_Load()
Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
Set rec1 = New ADODB.Recordset
Set rec2 = New ADODB.Recordset
Set rec3 = New ADODB.Recordset
conn.ConnectionString = "Provider=Microsoft.Jet.OlEDB.4.0;Data Source=" & App.Path & _
"\ParlourDesign.mdb;Persist Security Info=False"
conn.Open
sql = "select * from PartPayment"
sql2 = "select * from Receipt"
sql3 = "select * from ReceiptService"
sql4 = "select * from Service"
rec.Open (sql), conn, adOpenDynamic, adLockOptimistic
rec1.Open (sql2), conn, adOpenDynamic, adLockOptimistic
rec2.Open (sql3), conn, adOpenDynamic, adLockOptimistic
rec3.Open (sql4), conn, adOpenDynamic, adLockOptimistic
rec.MoveLast
rec.MoveFirst
Dim RR As Integer
FlexService.Clear
FlexService.Rows = rec.RecordCount + 1
FlexService.Cols = rec.Fields.count
FlexService.FixedCols = 0
FlexService.TextMatrix(0, 0) = "Service"
FlexService.TextMatrix(0, 1) = "Quantity"
FlexService.TextMatrix(0, 2) = "Price"
FlexService.TextMatrix(0, 3) = "Total"
rec.MoveFirst
RR = 1
Do While Not rec.EOF()
FlexService.TextMatrix(RR, 0) = rec.Fields("Service")
FlexService.TextMatrix(RR, 1) = rec.Fields("Quantity")
FlexService.TextMatrix(RR, 2) = rec.Fields("Price")
FlexService.TextMatrix(RR, 3) = rec.Fields("Total")
RR = RR + 1
rec.MoveNext
Loop
End Sub
And here's the code for PartPayment (FlexPP):
Private Sub Form_Load()
Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
Set rec1 = New ADODB.Recordset
Set rec2 = New ADODB.Recordset
Set rec3 = New ADODB.Recordset
conn.ConnectionString = "Provider=Microsoft.Jet.OlEDB.4.0;Data Source=" & App.Path & _
"\ParlourDesign.mdb;Persist Security Info=False"
conn.Open
sql = "select * from PartPayment"
sql2 = "select * from Receipt"
sql3 = "select * from ReceiptService"
sql4 = "select * from Service"
rec.Open (sql), conn, adOpenDynamic, adLockOptimistic
rec1.Open (sql2), conn, adOpenDynamic, adLockOptimistic
rec2.Open (sql3), conn, adOpenDynamic, adLockOptimistic
rec3.Open (sql4), conn, adOpenDynamic, adLockOptimistic
rec.MoveLast
rec.MoveFirst
Dim RR As Integer
FlexPP.Clear
FlexPP.Rows = rec.RecordCount + 1
FlexPP.Cols = rec.Fields.count
FlexPP.FixedCols = 0
FlexPP.TextMatrix(0, 0) = "PPID"
FlexPP.TextMatrix(0, 1) = "ReceiptNo"
FlexPP.TextMatrix(0, 2) = "PPDate"
FlexPP.TextMatrix(0, 3) = "AmountPaid"
rec.MoveFirst
RR = 1
Do While Not rec.EOF()
FlexPP.TextMatrix(RR, 0) = rec.Fields("PPID")
FlexPP.TextMatrix(RR, 1) = rec.Fields("ReceiptNo")
FlexPP.TextMatrix(RR, 2) = rec.Fields("PPDate")
FlexPP.TextMatrix(RR, 3) = rec.Fields("AmountPaid")
RR = RR + 1
rec.MoveNext
Loop
End Sub
Entering both of these "Form Load" codes in one form will be clashing. So what should I do?
Please help! :\