Delete text in bound textboxes ?

S

SpookiePower

I have a form with a lot of boundtextboxes on.
Each time I deleted the text in these textboxes,
I did it this way - Me.textbox = Null - But I found
out that I also deleted the text from the database,
which is not what I wanted to do. But how can I then
clear these textboxes, without deleting from the database ?

I tryed it this way - Me.textbox = '' - But it does not work.
 
J

Jeff Boyce

A bit of a primer on Access...

Access stores data in tables. You create a form that "looks at" a table
when you bind the form to the table, and bind the controls (e.g., text
boxes) to the table's fields.

If you delete the value in a form's bound textbox control, you are telling
Access to delete the value from the table.

You've described HOW you are trying to do something (delete something from a
textbox), but not WHY. If you'll explain WHY (i.e., what you are trying to
accomplish, without delving into the HOW), the newsgroup readers may be able
to offer alternative approaches.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
S

SpookiePower

Jeff said:
A bit of a primer on Access...

Access stores data in tables. You create a form that "looks at" a table
when you bind the form to the table, and bind the controls (e.g., text
boxes) to the table's fields.

If you delete the value in a form's bound textbox control, you are telling
Access to delete the value from the table.

You've described HOW you are trying to do something (delete something from a
textbox), but not WHY. If you'll explain WHY (i.e., what you are trying to
accomplish, without delving into the HOW), the newsgroup readers may be able
to offer alternative approaches.


I use this form to print out a custemor report.

The user can enter a custemor number and print a report.
But before the report is printet, the form is cleared so that
it is ready for another custemor.

Before the user print, the user can read these textboxes and see
if it is the right custemor that he/she choose to print.

But maybe I should show the custemor data in labels insted.
 
J

Jeff Boyce

Here's a generic approach to doing what you described...

Create a form based on a query of the table that holds your customer data.
In the form, add a combo box (unbound) in the form header. Base that combo
box on a query that returns the CustomerID and customer name (from the
customer data table). Set the first column width to 0.

Modify the query that underlies your form to point at that combo box, using
something like:
Forms!YourForm!YourComboBox
as the Selection Criterion for the CustomerID field.

Modify the combo box on your form by adding the following code in an
AfterUpdate procedure:
Me.Requery

All the above has the effect of giving you a way to pick a customer, then
see that customer's information.

Finally, add a command button to the form that prints your report. In the
command button's OnClick event, add something like:

DoCmd.OpenReport ,,...., Me!YourComboBox

Look up the proper syntax for the OpenReport command to see where you
include the CustomerID (from YourComboBox) to limit the report to that
customer's data.

Now, when you want to see another customer, pick one from the combo box. If
it's what you wanted, click the command button.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Top