I'm doing an inventory application in a random file, everything works fine, but I need to delete the record through combobox. I don't know what I'm doing wrong. It loads the data to the textboxes and when deleting the specific record it is not deleted
The program is made in Spanish, I suppose that there is no problem to see the problem of the program, thanks

Recommended Answers

All 3 Replies

now I can delete a record what is missing is to update the id
when a record is deleted, the id should be added to one
so that in the frmnuevoarticulo the id adds plus one

Dim ror As String


    ror = MsgBox("delete record: " + Text1.Text, 3 + 32, "delete")
    If (ror = vbYes) Then




  Dim I As Integer, Count As Integer

Open App.Path & "\inventario\inventario.txt" For Random As 1 Len = Len(inv)

Open App.Path & "\inventario\inventario.temp" For Random As 2 Len = Len(inv)


 With Combo1 'Adresses listbox
 Position = .ListIndex + 1 'marked entry position
 For I = 1 To .ListCount - 1 'I is used for position in random file
 If I <> Position Then
 Get #1, I, inv
 Count = Count + 1
 Put #2, Count, inv
 End If
 Next I
 .RemoveItem (.ListIndex)

 End With
 Close #1 'close orignal file
 Close #2 'close new temporary file




   Kill App.Path & "\inventario\inventario.txt"

   Name App.Path & "\inventario\inventario.temp" As App.Path & "\inventario\inventario.txt"




    End If

Combo1.ListIndex = 0
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text2.SetFocus

thank you

I don't know Spanish, so it was difficult for me to follow. As best I can determine, you are trying to use the NAME keyword to rename a file:

Name App.Path & "\inventario\inventario.temp" As App.Path & "\inventario\inventario.txt"

Name returns the name used in code to identify a form, control, or data access object, or returns or sets the name of a font object.

Instead, add a Reference to Microsoft Scripting Runtime, then use:

Dim fso As New FileSystemObject
fso.CopyFile App.Path & "\inventario\inventario.temp", App.Path & "\inventario\inventario.text"
Kill App.Path & "\inventario\inventario.temp"

Hello, the process of deleting a record does it well
the problem is that it does not update the id, which would be inv.id,
I try to add and save inv.id but it adds a repeated item in combo1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.