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

Records get saved without wanting it...

Status
Not open for further replies.

quibus

Technical User
Jul 18, 2002
8
BE
Hi,

I have a form where users have to fill in a keynumber and a name. On the same form, there is a subform with tabs, where they can check what keynumber belongs to what machine.
My problem is that when they fill in a name, and then click on a tab of the subform to check a key, the name is saved in my table without a keynumber (because they didn't fill it in yet). I only want the keynumber en name to be saved when they click OK.
Is there a solution for this.

Thx for helping a beginner!!
 
This wil fix it.. when the TxtName loses focus..

TxtName_lost focus

If IsNull(TxtKeyNo) then
msgbox "Please Enter a Key Number"
TxtKeyNo.SetFocus
end if

This will ensure that the there is text in the keynumber field before it loses focus and goes to the next field. Or you can do this when a field has got focus. let me know if this helps, or what else you need, if more complex.
you can also use the len fuction...

If len(TxtKeyNo) = 0 then
msgbox "Please Enter a Key Number"
TxtKeyNo.SetFocus
end if
"The greatest risk, is not taking one."
 
Thx for the code, this works!!! But I'd rather see the name- and numberfield cleared when they click on a tab in the subform. I tried it with Me.Undo. But it doesn't work. Maybe I didn't put it on the wright place (My knowledge of VB is very basic).
More suggestions???
 
What you are seeing is because your form is assigned to the table and your fields are assigned to the table fields. When you go to a different screen or move off of the current record for any reason access saves your changes. If you want to stop this then you will have to make all of your fields unbound (unassigned to any table). This, of course, would require that you handle all of the record handling yourself. It is not terribly difficult to do. Just tedious sometimes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top