Get data from previous entry in a text box (1 Viewer)

hrdpgajjar

Registered User.
Local time
Today, 06:55
Joined
Sep 24, 2019
Messages
91
HI all,
I have data entry form of client details entry.

In this form there are two text boxes 1. Client name (Farmer Name) 2. client city

This is a data entry form so when i click on save button all boxes will become empty for the new data entry. So to avoid duplicate entries, i have created a text box with lock properties to display my last entered client name.

to do this i have entered following code in "After Update" event of my client name text box

Code:
If Not IsNull(Me.Farmernametxt.Value) Then
        Previousentrytxt.DefaultValue = """" & Me.Farmernametxt.Value & """"
       
    End If

Every thing works fine, but when i save the record my form does not move to next empty record entry. (to enter new record) it stays the same.


How to solve this ?


Thanks
 
Why have an explicit SAVE button on the form. If you have a bound form as you move from one record to the next the data entered is validated (using before update form validations) and the new blank form appears with the next primary key. Navigation to a new record is straightforward.
You can avoid duplicate entry if you have a unique index on say FarmerName , if that is a valid rule, or any composite key - or you test for duplicate FarmerNames in the beforeUpdate event of the form). You then don't need to see the last entered name, because the validation will test for the duplicate name.
 
Why not use a continuous form set to data entry=true? You can then see all entries in the current session
 
HI all,
I have data entry form of client details entry.

In this form there are two text boxes 1. Client name (Farmer Name) 2. client city

This is a data entry form so when i click on save button all boxes will become empty for the new data entry. So to avoid duplicate entries, i have created a text box with lock properties to display my last entered client name.

to do this i have entered following code in "After Update" event of my client name text box

Code:
If Not IsNull(Me.Farmernametxt.Value) Then
        Previousentrytxt.DefaultValue = """" & Me.Farmernametxt.Value & """"
      
    End If

Every thing works fine, but when i save the record my form does not move to next empty record entry. (to enter new record) it stays the same.


How to solve this ?


Thanks
I don't know the rules for what constitutes a "FarmerName" in your context, but I'm wondering if it is even possible to prevent duplicates values.

First, though, we ought to be clear about what constitutes a valid FarmerName. Are you working with people who have only one name? If so, a single field in the table is appropriate. However, around the world in most societies it is quite common to have two or more names. So, if you are combining such names into a single field, there is a flaw in the table design.

But granting that your database really does track people (or organizations) with single names, can you really guarantee that no two Farmers will ever have the same name? I would not think that you can enforce a unique restraint on this field in a real world scenario.

That said, if you really want to prevent saving duplicates you can add a unique index to this field and let the database engine handle it for you.
 
Every thing works fine, but when i save the record my form does not move to next empty record entry. (to enter new record) it stays the same.

This is actually the default behavior of Access. First, if you want a SAVE button, that is OK to have but not necessary since Access would automatically save the old record if you navigate to a new one. If your navigation controls are still available at the bottom of the form because you hadn't turned them off, a "new record" and a "save current record" option are part of those controls.

But then there is the issue that if you ever wanted to use your form to EDIT an existing record, and if you DID implement an automatic "new record" action on a SAVE, then the moment you saved that record, you would create a new record which, for the editing case would mean you have to then CANCEL the new record. Beware of too much automation.

If you created that SAVE button using the button wizard, you should see that creating another button would allow you to build a "new record" action which would be a separate explicit action - but unequivocal in intent.
 
If you are trying to make the previous FarmerName the current FarmerName, then you have a design flaw since FarmerName should be unique and exist only once and not be repeated in every row. If you have related tables, the child table has the FK of the parent table but NOT any data fields,
 

Users who are viewing this thread

Back
Top Bottom