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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CAN YOU ERASE DATA IN A FORM, OR CONCENTRATE ON ONLY 1 LINE? 1

Status
Not open for further replies.

billquga

Technical User
Aug 23, 2001
19
US
Hello all. I open a form to enter data on only one line. then i print a report based on this one line. Is it possible, that when i'm done printing this record, the information is deleted? Because the next time i go into the form to enter data, i only want that line to print. and if if the information isnt deleted, it will print both lines. Any help would be appreciated.
 
If the form is still open when the report is printing then you should be ablt to do it. In the OnClose event of the report put the following code in(Change the generic names to match yours)

Forms!YourFormName!TheEditBox = ""
What this will do is place a blank string into the box, I have several areass in th systems I work on and this is how I got around it. If this doesn't work at .Value at the end of the name of the edit box. If it still doesn't work just let me know.

Chris
 
Chris, thank you very much for your responce. I do understand what your saying, but when I attempt it, it seems to not work. I copied the code you gave me, placed it in the Onclose section of the report. I changed where you put [YourFormName] to the title of the form. Do i have to change the [TheEditBox] to something that is specific to my form? When i open the report, everything is OK. When I close the report I get the following error message:

MICROSOFT ACCESS CAN'T FIND THE MACRO 'FORMS!ADDRESS LABEL!TheEditBox-" "
THE MACRO [OR ITS MACRO GROUP]DOSENT EXIST, OR THE MACRO IS NEW BUT HASN'T BEEN SAVED.
NOTE THAT WHEN YOU ENTER THE MACROGROUPNAME.MACRONAME SYNTAX IN AN ARGUMENT, YOU MUST SPECIFY THE NAME THE MACRO'S MACRO GROUP WAS LAST SAVED UNDER.

In my form, I have the following fields to enter on.
Address Line 1
Address Line 2
Address Line 3
City
State
Zip
Number of copies.
After i enter this information into the form, i run a label report. it knows how many labels to print by looking at the number of copies field. But after I'm done with this address label, I would like the form data to be deleted so I can start next time with a clean slate. Any further help would truly be appreciated.
 
You have to change TheEditBox to the name of the edit box or control that you are entering the text into
 
I'm sorry, I just must not understand this. I understand that I change the [MyFormName] to the name of the form. But if I want to erase the entire line that is stored in the table, but entered in the form, what do I replace the [TheEditBox] with to acomplish this. If I enter the name of the first field, wont it only erase the first field?
 
I think the confusion is one of terminolgy. If I uderstand this correctly, billguga is referencing a line in his database table which is really a record.....that includes several different address fields...

I'm not sure why you'd be using an access database if your not going to keep the addresses in there once you've typed them in.....but if that's truely the case then just run a delete query before you close the form.

DoCmd.RunSQL "DELETE TableName.* FROM TableName;"

Simply replace TableName with the name of your table.
WARNING: The above will erase all records in that database table!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top