Table Data

bizzy

Registered User.
Local time
Tomorrow, 00:10
Joined
Jul 13, 2005
Messages
17
Hi Guys/Girls,

I have a database that contains Temporary workers names. They need to be able to add a new Temp worker, however currently the TempID is an autonumber and with my current set-up (which I'm sure is wrong) when they open the Add New Temp form and type just a single letter but decide they didn't mean to do that it still adds that to the temp table. Even if the remove the letter/number typed.

So my question is How do I make my form not add the Data to the Table until they hit the save button?

Cheers

Bizzy
 
This is the way autonumbers work. It is not a problem. Just ignore the gaps. Primary keys are not supposed to have any meaning, they only need to be unique.
 
But.....

I understand that, maybe I should have added this into the original post. Sorry. The temp name is used as a lookup in another table and when you view the list it has blanks in it. Can you stop this?
 
Sorry I didn't understand your original question. I thought you were talking about the discarded autonumbers. To prevent records from being saved until they are complete, modify the table design and change the required property of the required fields to Yes.

If you want to control saving the current record with a save button, you need to add a public variable to your form's class module and you need to set its value at three places and check its value in one place.

Code:
Dim bSave as Boolean

Open event
bSave = False

Click Event of Save button
bSave = True
DoCmd.RunCommand acCmdSaveRecord

BeforeUpdate event of FORM
If bSave = False
    If MsgBox("Do you want to save?", vbYesNo) = vbYes
    Else
        Cancel = True
    End If
End If
bSave = False
 

Users who are viewing this thread

Back
Top Bottom