Hey, I'm using the following code to write entries to a data file and then read them in an msflexgrid. I now would like to add code under a delete button to use the table(grid) to delete rows from the file. How can I do that. I have some code for deleting a row from the table, but it's only deleting the row from the table, and not the entry itself. Please help! Is there a relatively easy way to do this ?
Private Sub cmdAddDelivery_ Click()
Open App.Path & "\deliveries.tx t" For Append As #11
Write #11, lblAccNum.Capti on, txtPName.Text, txtPAddress1.Te xt & ", " & txtPAddress2.Te xt & ", " & cboPTown.Text, cboPPrefix.Text & " " & txtPTelephone.T ext & ", " & cboPMPrefix.Tex t & " " & txtPMobile.Text , txtDName.Text, txtDAddress1.Te xt & ", " & txtDAddress2.Te xt & ", " & cboDTown.Text, cboDPrefix.Text & " " & txtDTelephone.T ext & ", " & cboDMPrefix.Tex t & " " & txtDMobile.Text , txtWeightOfPack age.Text, txtDeliveryPric e.Text, txtPickupDate.T ext, txtDeliveryDate .Text, lblPriorityLeve l.Caption
MsgBox "New Delivery has been Added !", vbInformation, "Success!!! "
txtPName.Text = ""
txtPAddress1.Te xt = ""
txtPAddress2.Te xt = ""
cboPTown.Text = ""
cboPPrefix.Text = "021"
txtPTelephone.T ext = ""
cboPMPrefix.Tex t = "085"
txtPMobile.Text = ""
txtDName.Text = ""
txtDAddress1.Te xt = ""
txtDAddress2.Te xt = ""
cboDTown.Text = ""
cboDPrefix.Text = "021"
txtDTelephone.T ext = ""
cboDMPrefix.Tex t = "085"
txtDMobile.Text = ""
txtWeightOfPack age.Text = ""
txtDeliveryPric e.Text = ""
txtPickupDate.T ext = ""
txtDeliveryDate .Text = ""
txtPName.SetFoc us
Close #11
End Sub
Private Sub tabAdmin_Click( PreviousTab As Integer)
If tabAdmin.Tab = 1 Then
Open App.Path & "\deliveries.tx t" For Input As #12
Dim oldRow As Long
Dim lngRow As Long
Dim lngCol As Long
Dim tRow As Long
Dim tCol As Long
Dim strID As String
Dim strPickupName As String
Dim strPickupAdd As String
Dim strPickupTel As String
Dim strDelName As String
Dim strDelAdd As String
Dim strDelTel As String
Dim strWoP As String
Dim strDelPrice As String
Dim strPickupDate As String
Dim strDelDate As String
Dim strPriority As String
Dim counter As Integer
MSFlexGrid1.Row s = 2
Do Until EOF(12)
Input #12, strID, strPickupName, strPickupAdd, strPickupTel, strDelName, strDelAdd, strDelTel, strWoP, strDelPrice, strPickupDate, strDelDate, strPriority
MSFlexGrid1.Tex tMatrix(1, 0) = strID
MSFlexGrid1.Tex tMatrix(1, 1) = strPickupName
MSFlexGrid1.Tex tMatrix(1, 2) = strPickupAdd
MSFlexGrid1.Tex tMatrix(1, 3) = strPickupTel
MSFlexGrid1.Tex tMatrix(1, 4) = strDelName
MSFlexGrid1.Tex tMatrix(1, 5) = strDelAdd
MSFlexGrid1.Tex tMatrix(1, 6) = strDelTel
MSFlexGrid1.Tex tMatrix(1, 7) = strWoP
MSFlexGrid1.Tex tMatrix(1, 8) = strDelPrice
MSFlexGrid1.Tex tMatrix(1, 9) = strPickupDate
MSFlexGrid1.Tex tMatrix(1, 10) = strDelDate
MSFlexGrid1.Tex tMatrix(1, 11) = strPriority
MSFlexGrid1.Row s = MSFlexGrid1.Row s + 1
For lngRow = MSFlexGrid1.Row s - 2 To MSFlexGrid1.Row Step -1
For lngCol = 0 To MSFlexGrid1.Col s - 1
MSFlexGrid1.Tex tMatrix(lngRow + 1, lngCol) = MSFlexGrid1.Tex tMatrix(lngRow, lngCol)
If lngRow = MSFlexGrid1.Row Then
MSFlexGrid1.Tex tMatrix(lngRow, lngCol) = "" 'Make the current row empty
End If
Next
Next
Loop
End If
Close #12
End Sub
Private Sub cmdAddDelivery_ Click()
Open App.Path & "\deliveries.tx t" For Append As #11
Write #11, lblAccNum.Capti on, txtPName.Text, txtPAddress1.Te xt & ", " & txtPAddress2.Te xt & ", " & cboPTown.Text, cboPPrefix.Text & " " & txtPTelephone.T ext & ", " & cboPMPrefix.Tex t & " " & txtPMobile.Text , txtDName.Text, txtDAddress1.Te xt & ", " & txtDAddress2.Te xt & ", " & cboDTown.Text, cboDPrefix.Text & " " & txtDTelephone.T ext & ", " & cboDMPrefix.Tex t & " " & txtDMobile.Text , txtWeightOfPack age.Text, txtDeliveryPric e.Text, txtPickupDate.T ext, txtDeliveryDate .Text, lblPriorityLeve l.Caption
MsgBox "New Delivery has been Added !", vbInformation, "Success!!! "
txtPName.Text = ""
txtPAddress1.Te xt = ""
txtPAddress2.Te xt = ""
cboPTown.Text = ""
cboPPrefix.Text = "021"
txtPTelephone.T ext = ""
cboPMPrefix.Tex t = "085"
txtPMobile.Text = ""
txtDName.Text = ""
txtDAddress1.Te xt = ""
txtDAddress2.Te xt = ""
cboDTown.Text = ""
cboDPrefix.Text = "021"
txtDTelephone.T ext = ""
cboDMPrefix.Tex t = "085"
txtDMobile.Text = ""
txtWeightOfPack age.Text = ""
txtDeliveryPric e.Text = ""
txtPickupDate.T ext = ""
txtDeliveryDate .Text = ""
txtPName.SetFoc us
Close #11
End Sub
Private Sub tabAdmin_Click( PreviousTab As Integer)
If tabAdmin.Tab = 1 Then
Open App.Path & "\deliveries.tx t" For Input As #12
Dim oldRow As Long
Dim lngRow As Long
Dim lngCol As Long
Dim tRow As Long
Dim tCol As Long
Dim strID As String
Dim strPickupName As String
Dim strPickupAdd As String
Dim strPickupTel As String
Dim strDelName As String
Dim strDelAdd As String
Dim strDelTel As String
Dim strWoP As String
Dim strDelPrice As String
Dim strPickupDate As String
Dim strDelDate As String
Dim strPriority As String
Dim counter As Integer
MSFlexGrid1.Row s = 2
Do Until EOF(12)
Input #12, strID, strPickupName, strPickupAdd, strPickupTel, strDelName, strDelAdd, strDelTel, strWoP, strDelPrice, strPickupDate, strDelDate, strPriority
MSFlexGrid1.Tex tMatrix(1, 0) = strID
MSFlexGrid1.Tex tMatrix(1, 1) = strPickupName
MSFlexGrid1.Tex tMatrix(1, 2) = strPickupAdd
MSFlexGrid1.Tex tMatrix(1, 3) = strPickupTel
MSFlexGrid1.Tex tMatrix(1, 4) = strDelName
MSFlexGrid1.Tex tMatrix(1, 5) = strDelAdd
MSFlexGrid1.Tex tMatrix(1, 6) = strDelTel
MSFlexGrid1.Tex tMatrix(1, 7) = strWoP
MSFlexGrid1.Tex tMatrix(1, 8) = strDelPrice
MSFlexGrid1.Tex tMatrix(1, 9) = strPickupDate
MSFlexGrid1.Tex tMatrix(1, 10) = strDelDate
MSFlexGrid1.Tex tMatrix(1, 11) = strPriority
MSFlexGrid1.Row s = MSFlexGrid1.Row s + 1
For lngRow = MSFlexGrid1.Row s - 2 To MSFlexGrid1.Row Step -1
For lngCol = 0 To MSFlexGrid1.Col s - 1
MSFlexGrid1.Tex tMatrix(lngRow + 1, lngCol) = MSFlexGrid1.Tex tMatrix(lngRow, lngCol)
If lngRow = MSFlexGrid1.Row Then
MSFlexGrid1.Tex tMatrix(lngRow, lngCol) = "" 'Make the current row empty
End If
Next
Next
Loop
End If
Close #12
End Sub
Comment