How can I not save certain data?

S

scooterspal

Hello and thanks for any help you can provide. I'm new to Access
and I'm in the process of creating a very simple order form to take
phone orders with. Nothing too complicated.

One section is where we will input the customer's credit card information.

Question 1: Is there a way to have this information automatically
purged from the record after some period of time?

Question 2: If this is not possible, is there a way to have it
purged when we go to save the record intially (after we print out
the order)?

Thanks!
 
B

BruceM

If the idea is not to save the sensitive information, the best choice may be
to enter it into an unbound text box on the form. When you print the
report, refer to the name of the form and the text box.

Assuming your form is named frmOrder, and the credit card text box is
txtCCard, in an unbound text box on the report put this as the Control
Source:
=Forms!frmOrder!txtCCard

This assumes you are printing a report, not the form. Reports are best for
printing, for many reasons. However, if you are printing the form, just put
the information into an unbound text box. It is not associated, so the
information won't be saved.because there is no place to save it.

You have not described your database structure, but if you are using a
single table for all this it would be best to rethink the design before you
get too far. This link has useful information on the fundamentals of
relational database design (and many other things):
http://allenbrowne.com/casu-22.html

Allen Browne's web site is one of many excellent resources on the web.
Along with hosting Crystal's tutorial he provides examples and tips for
users at all levels:
http://allenbrowne.com/tips.html

There is also an extensive collection of links to other Access web sites:
http://allenbrowne.com/links.html
 
S

scooterspal

BruceM said:
If the idea is not to save the sensitive information, the best choice
may be to enter it into an unbound text box on the form. When you print
the report, refer to the name of the form and the text box.

Thank you for your kind reply. Much appreciated!

As it turns out, this section has all "unbound" boxes so I assume the
data is not being saved. However, when we go to the next record all that
information is left there. The other boxes are getting cleared.

Is there any way to have it (the unbound boxes) clear or do we need to
delete each entry manually?
 
B

BruceM

If all are unbound, nothing is being saved.

Without seeing the database I couildn't be sure why the other text boxes are
being cleared, but you can clear the check box in the form's Current event,
or when you print the report, or any number of other places. The code would
be something like:

Me.txtCCard = Null
 
S

scooterspal

BruceM said:
The code would be something like:

Me.txtCCard = Null

Thanks but I'm not sure what to do with this bit of code.

What I did, which may have been a mistake, was take the template
already in Access 97 for order form and move things around and rename
and add text boxes, check boxes, etc. The form works more or less
but is not clearing the boxes I added. Only the ones that appeared
in the template... that are "bounded" I guess is the proper word.

This has the customer's name and address info which we do want to save
for future use. This is followed by a section for credit card info which
we want to not save. All these text boxes are "unbound".

Under this is another section for what they want to order. Mostly check
boxes. Again, we do not have to save this.

Is there a single "switch" or bit of code I can place somewhere for each
that will clear the check box or the text box when we either advance to
the next record after we print the form or create a button to do this
cleaning for us?

Thanks!
 
B

BruceM

A form or report usually has a Record Source, which is a table or query
containing the records that are to appear on the form or report. A bound
control is one that has a field in the Record Source as its Control Source.
A control, by the way, is a text box, combo box, check box, line, command
button, label, or just about anything that can appear on a form or report.
Not all controls can be bound. A label or line, for instance, cannot be
associated with a field.

If a control is bound and you move to a record that has no data in that
field there will be nothing in that control. For instance, in a table that
lists people and their addresses, an apartment number field should be blank
if the person lives in a house.

To place code in the form's Current event, open the form in design view,
then click View >> Properties. This will open what is called the Property
Sheet (if it is not already open), with tabs for Format, Data, Event, Other,
and All. Click the Event tab, and click next to On Current. Click the
three dots that appear to the right of the On Current row, then click Code
Builder, then OK. This will open the VBA editor. You should see:

Private Sub Form_Current()

End Sub

The cursor should be flashing between those two lines. Type:
Me.txtCCard = Null

After you type "Me" plus the dot you will probably be presented with a list
of choices for controls, fields, and so forth. You should be able to select
the text box name from the list, or you can just type the whoe thing. When
you are done entering code, click Debug >> Compile.

Repeat for other unbound text boxes.

You can add the same code to the report's Close event, using the same
general technique except with the report open in design view. Similarly,
you can use a command button, adding the code to the Click event. I would
think clearing the text boxes automatically would be preferable, but the
point is that you have choices.
 
M

Mrs. Ugh

I'm not sure you even need to use code, on the Property sheet of the Credit
Card text box, go to the Data tab. find the line that says Default Value and
type "" on the line. This will clear the box when you go to a new record.
Jill
 
B

BruceM

It won't clear an unbound text box, in my experience. That being said, it
feels like I'm overlooking a simpler solution than I have suggested, but I
don't know if that's true or what it may be.
 
S

scooterspal

Thank you Bruce. I will give this a try.

BTW: Just placing the "" as someone else suggested
did not work. The value remains when you go to the
next record.
 
B

BruceM

Help is not explicit about the subject that I can see, but DefaultValue does
not apply to unbound controls.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top