Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving Values to a textfile problem....

Status
Not open for further replies.

frontside

Technical User
Sep 26, 2002
85
SE
I´m doing some calculations in the "on formatting" on details.... the result of this calculation is then put in a textfile using this code (its only 1 and 0 )

Dim Strantal as string
Open "c:\antal.txt" For Append As #1
strantal = Me.oomantal
Write #1, strantal
Close #1

antal.txt
1
0
1
0
0
0
1
1


I use this information as a base for another report, the problem is that I get the wrong number of values. After some testing I realized that it(access) first puts all the values in the textfile and when Access loads the report into memmory and that way it puts the values once again in the textfile.
If the report is shorter than 3-4 pages I then get the values two times and if the report is longer I get the values once plus how many values access has put in memmory (how many pages access has formatted). If I then go to last page it puts all the values and gives the same result as a shorter report(all the values twice).

My question is, how do I put the value in the textfile only once (is there a way to do a loop who can fix this?, check where the last value is) or is there some other way that I could get this thing to work?

Would love some ideas about my problem


Micke "Sweden"
 
Hi

Maybe FormatCount will help?

FormatCount An Integer value that specifies whether the Format event has occurred more than once for a section. For example, if a section doesn't fit on one page and part of it moves to the next page of the report, Microsoft Access sets the FormatCount argument to 2.

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanks for the idea, Ken

I´m looking into how formatcount works. If I put me.AReportfield = formatcount that gives me a 2(on the first value on a page)....
But it still doesnt explain how every value is put in the textfile twice (since the value is moved twice the formatcount should also be a 2, (in a perfect world that is :)).

I´m going to try to do some code using the formatcount but I still would love some more ideas!

micke "Sweden"



 
I have made a small database that will show the problem,

The report has a few nice little features that anyone can use, I would also like any comments of how to make the code better or if there´s a better way to face the problem. (exept namestandard that I havent used of the testdatabase :)

I have tried to explain how I would want the result to be but If you have any questions, just send me an email.


Here´s a link to download the problem!!




Thanks for all the help!!!

micke "sweden"
 
I found a solution by doing a query on the table (from the textfile) and then group the result so that I only get the values once, works great!

I´m still interested in skipping the textfile and export directly to a table in access, so if there´s anyone out there that has done such a solution, let me know...

micke
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top