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

Error checking: changing existing values

Status
Not open for further replies.

avgeorge

MIS
Dec 6, 2004
3
US
Hi,
I am creating a form which contains a subform. A serial # is what link both tables together (a one to many setup). My form is conceptually similar to something I found on the web. I am almost done, but I think my debugging skills outweigh my coding skills, and I have come up with a problem that I can not solve in Access. If you look at the 3rd picture, you will notice a serial#. I ask for an ID#. For every ID#, multiple descriptions can be inserted. Problem is that if I entered 6 ID#s in, and were to accidentally scroll back through list and type a digit or character in the ID box with an ID# highlighted, it will create a new record in my subform table and practically overwrite my original ID# from the form table, but leaving it in the subform table as an unused record. How can I prevent this from happening? How can I reduce # of false/unlinked records?
One way I thought this could be prevented was to have an error msg pop up saying that data has been changed or just plain lock the ID# box, but this will not allow for me to insert new ID#s if needed. Can anyone help?
 
So it sounds like if there already something in the ID field, you don't want it changed. But if it's a new record, you want to allow it to be changed (edited/add another record). right?

So in the ID's OnEnter event, you can put this:
Code:
    If Me.NewRecord Then
        Me.item_number.Locked = False
    Else
        Me.item_number.Locked = True
    End If
and it will do just that.

(the cooler one-liner way would be:
Code:
    Me.item_number.Locked = Not (Me.NewRecord)
but I thought I'd write it all out first so you can see how it works.)

Hope this helps--g
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top