1.11M Members

Messed up Flex Grid code

 
0
 

So I've FINALLY gotten my code to work but unfortunately my code's sooo messed up that its displaying something else!
As you can see in the picture below, the Flex Grid is displaying the data of "Service"

http://i213.photobucket.com/albums/cc228/rose_408/receiptform_zps1a66f838.png

http://i213.photobucket.com/albums/cc228/rose_408/service_zps5e886a12.png

When its actually supposed to show the data of "Receipt Service"!
http://i213.photobucket.com/albums/cc228/rose_408/receiptservice_zps744a31ef.png

I just need help in finding out that what code is responsible for doing all this, so that i can make changes to it.

Heres my code:

 Private Sub Form_Load()
    Set connS = New ADODB.Connection
    Set RSservice = New ADODB.Recordset
    Set RSPartPayment = New ADODB.Recordset
    Set RSReceipt = New ADODB.Recordset
    Set RSReceiptService = New ADODB.Recordset

    connS.ConnectionString = "Provider=Microsoft.Jet.OlEDB.4.0;Data Source=" & App.Path & _
    "\ParlourDesign.mdb;Persist Security Info=False"

    connS.Open
    SQLReceiptService = "select * from ReceiptService"
    SQLservice = "select * from Service"
    SQLPartPayment = "select * from PartPayment"
    SQLReceipt = "select * from Receipt"


    RSservice.CursorLocation = adUseClient
    RSPartPayment.CursorLocation = adUseClient
    RSReceipt.CursorLocation = adUseClient
    RSReceiptService.CursorLocation = adUseClient

    RSReceiptService.Open (SQLReceiptService), connS, adOpenDynamic, adLockOptimistic
    RSservice.Open (SQLservice), connS, adOpenDynamic, adLockOptimistic
    RSPartPayment.Open (SQLPartPayment), connS, adOpenDynamic, adLockOptimistic
    RSReceipt.Open (SQLReceipt), connS, adOpenDynamic, adLockOptimistic



    RSReceipt.MoveLast
    RSReceipt.MoveFirst

    Call updateScr
    Call updGrd

    RSReceiptService.MoveFirst
    Do While Not RSReceiptService.EOF
    cmbreceipt.AddItem RSReceiptService.Fields(1)
    RSReceiptService.MoveNext
    Loop

End Sub



Private Sub flexreceipt_Click()
 Select Case FlexReceipt.Col
        Case 6: chkSelect.Visible = True
                chkSelect.Left = FlexReceipt.Left + FlexReceipt.CellLeft
                chkSelect.Top = FlexReceipt.Top + FlexReceipt.CellTop
                If FlexReceipt.Text = "Selected" Then
                    chkSelect.Value = "1"
                Else
                    chkSelect.Value = "0"
                End If
                chkSelect.SetFocus
                chkSelect.Visible = True
        lrow = FlexReceipt.Row
        lcol = FlexReceipt.Col
    End Select
End Sub





Private Sub flexreceipt_DblClick()
Select Case FlexReceipt.Col
Case 0, 6: 'Receipt No
    Exit Sub
Case 1, 3, 5: 'Text Boxes
            GridEdit Asc(" ")

Case 2: 'cmbreceipt
            cmbreceipt.Left = FlexReceipt.CellLeft + FlexReceipt.Left
            cmbreceipt.Top = FlexReceipt.CellTop + FlexReceipt.Top
            cmbreceipt.Width = FlexReceipt.CellWidth
            cmbreceipt.Visible = True
            cmbreceipt.Text = FlexReceipt.TextMatrix(FlexReceipt.Row, FlexReceipt.Col)
            cmbreceipt.SetFocus
End Select
End Sub




Private Sub updGrd()

Dim RR As Integer

SQLReceiptService = "select * from ReceiptService Where Service = " & txtreceiptno
RSReceiptService.Close
RSReceiptService.Open (SQLReceiptService), connS, adOpenDynamic, adLockOptimistic

FlexReceipt.Clear
FlexReceipt.Rows = IIf(RSReceiptService.RecordCount < 0, 1, RSReceiptService.RecordCount + 1)
FlexReceipt.Cols = RSReceiptService.Fields.count - 1
FlexReceipt.FixedCols = 0
FlexReceipt.TextMatrix(0, 0) = "Service"


If RSReceiptService.EOF Then Exit Sub
RSReceiptService.MoveFirst
RR = 1
Do While Not RSReceiptService.EOF()

    FlexReceipt.TextMatrix(RR, 0) = Service(RSReceiptService.Fields(1))
    RR = RR + 1
    RSReceiptService.MoveNext
Loop
End Sub






Function ServiceName(Tname As String) As Integer
RSservice.MoveFirst
Do While Not RSservice.EOF
    If RSservice.Fields(1) = Tname Then
        ServiceName = RSservice.Fields(0)
        Exit Do
    End If
    RSservice.MoveNext
Loop
End Function





Function Service(TID As Integer) As String
RSservice.MoveFirst
Do While Not RSservice.EOF
    If RSservice.Fields(0) = TID Then
        Service = RSservice.Fields(1)
        Exit Do
    End If
    RSservice.MoveNext
Loop
End Function





Private Sub updateScr()
If RSReceipt.EOF = True Or RSReceipt.BOF = True Then Exit Sub

If Not IsNull(RSReceipt.Fields(0)) Then
    txtreceiptno = RSReceipt.Fields(0)
End If

txtcustomer = IIf(Not IsNull(RSReceipt.Fields(1)), RSReceipt.Fields(1), "No Name")
txttotalamount = IIf(Not IsNull(RSReceipt.Fields(3)), RSReceipt.Fields(3), "No Amount")
End Sub

So how do I make "Receipt Service"s data show instead of "Service"?
Theres code for all the buttons too, but I'm sure that has got nothing to do with this...

Oh, and an other question! WHY is the date being displayed in the "Customer" field when its actually suppose to display the customers name!? :\

Thanks in Advance! :)

 
0
 

This part is incorrect, change code -

SQLReceiptService = "select * from ReceiptService Where Service = " & txtreceiptno

SQLReceiptService = "select * from ReceiptService Where Service = '" & txtreceiptno & "'"
 
0
 

Yay, it worked! Thanks again! ^_^

Question Answered as of 1 Year Ago by AndreRet
 
0
 

Only a pleasure. Happy coding... :)

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article