Hi, I've created a program to be used in a school to monitor the stock of equipment. a student is able to loan stock out, which should as a result drop the ammount of stock by 1 and increase a tally of the total loans for that piece of stock by 1. The coding works to the point that the stock drops, however all of the information writes back to a .text files, yet it isnt updating within the file.

I hope this makes sense,

Cheers

Code:
 Public Sub Loan()
Dim recordnumber As Integer
Dim found As Boolean
Dim ProductID As String
Dim product As OneProduct
Dim totalloans As Integer


ProductID = Form1.txtfindproduct.Text
recordnumber = 0
found = False
Filename = Form1.txtfilename.Text
Open Filename For Random As #1 Len = Len(product)
Do While (Not EOF(1)) And (found = False)

    recordnumber = recordnumber + 1
    Get #1, recordnumber, product
    If product.ProductID = ProductID Then
    found = True
    Form1.lblproductID.Caption = ProductID
    Form1.lbldescription.Caption = product.Description
    Form1.lblprice.Caption = product.Price
    Form1.lblquantityinstock.Caption = product.QuantityInStock
    Form1.txttotalloans.Text = Form1.txttotalloans.Text + 1
    product.totalloans = Form1.txttotalloans.Text
    
    product.QuantityInStock = Form1.lblquantityinstock.Caption
    
    Put #1, recordnumber, product
   End If

   Loop
    Close #1
    If Not found Then
    MsgBox ("Product ID " & ProductID & " is not in the file")
    End If
    
    product.QuantityInStock = Form1.lblquantityinstock.Caption
    product.totalloans = Form1.txttotalloans.Text
    lstdisplayfile.Clear
    Open Filename For Random As #1 Len = Len(product)
Put #1, recordnumber, product
MsgBox (product.ProductID)
    
MsgBox (product.totalloans)
MsgBox (product.QuantityInStock)

Close #1
    


    
End Sub