Solved

how to modify a line of data

Posted on 2002-04-29
2
139 Views
Last Modified: 2010-05-02
need help on the following code.


Private Sub Command1_Click()
X1% = 1
Do While X1% <= Max%
X1% = X1% + 1
Loop
Open "C:\invoice\dollar.dat" For Append As #3
    Form3.Text1.Text = inv  'invoice #
    Form3.Text2.Text = ddate  'date
    Form3.Text3.Text = amt  'amount
   
    Form3.Text4.Text = amt5  ' amt * 5%
    Form3.Text5.Text = deal  'dealer
    Form3.Text6.Text = paid

Do While X1% <= Max%
    Write #3, inv(X1%), ddate(X1%), amt(X1%), amt5(X1%), deal(X1%), paid(X1%)
    X1% = X1% + 1
    Loop
Close #3

End Sub


I want to change the one line of data to show that the invoice has been paid by entering a "y" oe "yes" into the "paid" area.....without changing ANY other data for this line (inv,ddate,amt,amt5,deal, paid) or any other data in the total file.
0
Comment
Question by:hjaycox
2 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 6979317
Your code doesn't make muh sense.

Does the data have to end up in the same file?
The way you have this written you are opening the file at the end, never reading from it and then writing something back to it.

I think you need to look at how to read/write from a random access file.  I don't have any VB books here nor do I know how to do it.

The general algorithm will be

Open to file
loop
  read next record
  if it one you want to edit 'this will allow you to edit
    edit record               'multiple records
    backup one reocrd
    write the record
  endif
end loop

good luck
mlmcc
0
 
LVL 3

Accepted Solution

by:
n_narayanan earned 200 total points
ID: 6979605
You have to use Random files instead of Sequencial Access.

http://www.freevbcode.com/ShowCode.Asp?ID=2673
http://www.freevbcode.com/ShowCode.Asp?ID=315

Check the above links

Cheers

Narayanan
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now