Blank record creation

agehoops

Registered User.
Local time
Today, 19:12
Joined
Feb 11, 2006
Messages
351
On my main form for entering staff details, every time I create a new record, 3 of the 4 sub forms create 1 blank record with absolutely no link to anything, just completely blank. I looked on the forum and found a similar problem in that if you set the focus from the main form to the subform this would happen, so i removed all traces of that happening, and it reduced it from 3 to 1 but it is still doing it. Just weird that it is only doing it for 3 of the 4 sub forms??

Thanks
 
Moving the focus from a SubForm to another SubForm or the MainForm will try and save the record if it is dirty. You must be doing something in that SubForm to dirty the record.
 
If you have any default values set it will also look like it is starting a new record, but really isn't unless (as Allan suggests) that something is causing it to try to save.
 
I think i got rid of all of the default values for that reason. I will check through it all again. What other sort of things would cause it to be 'dirty' other than the setting of focus?
 
The only thing I can think of is that some code is setting a value in the form (creating your own autonumber, via DMax + 1, and having it entered before the before update event could do it).
 
Alright I'll take a look through all the code (could take a while) and post back if I find anything or if not to try and figure it out.

Thanks
 
Ok had a quick look through, and now it's creating 3 blank records each time! :(
 
Both Bob and I and perhaps others will arm wrestle it! :D
 
Alright give me a sec. I'll upload it to another server, bit big for here and seeing as i'm not certain which part is causing the problem i'll leave it all as is
 
ok managed to shrink it. Took out all the forms completely un related.

Ok in order for this all to work you'll need to copy the .bas file and the .dll file into the same folder as the main db. The backend will be updated when the database runs (it will prompt you to update)

You HAVE to login through the login form for it to work as well as there is a lot of code depending on it. When you get to the main menu, open the staff form, all the others have been deleted.


Thanks for looking

View attachment Database.zip
 
What version of Access are you using? Did you try to compile this code?
 
I'm using 2007 here but most of it was written while using 2003. Yea i know the code is pretty bad and extremely repetitive, just didn't know any other way of doing it :P
 
It is probably getting late there: 23:22? Which table is getting the three blank records and what do we have to do to get it to hickup. So far it is not doing it for me.
 
Can you list out exactly what we should be looking at? Which form and all? I'm not sure exactly which to look at. What is getting the new records?
 
Sorry, should've made that quite clear. Yea it was getting a bit late RG so sorry for the delayed response.

Open up the tables tblNVQ, tblAppraisals, tblTraining, and tblSupervisions, and delete any blank records that are there (some don't have any data, but others don't even have a value for the foreign key, so delete these ones if there are any)
Login to the system through the login screen ( user : Admin, password: test)
Open the Staff form (may give you errors on the locations of the pictures)
Create a new member of staff (button to the right hand side)
Fill in some random details on the first tab, then in the training tab, NVQ tab, appraisals tab and supervisions tab, then close the form.
Go into the tables: tblNVQ, tblAppraisals, tblSupervisions, and tblTraining.
tblTraining should have only the record you created, for some reason it doesn't create blanks in this table.
The other 3 tables will (or at least should) have a couple or a few blank records as well as the one you just created.

Thanks for looking :)
 
I've added some MsgBox's to the BeforeUpdate event of several SubForms. This event *only* occurs because Access is saving a record. Now you can see when the events are happening as you complete your form. Writing to a bound control in the Current event of a form will almost certainly "Dirty" the record, even if the data is the same as what is already in the control!
 

Attachments

wo thanks. Didn't realise it was doing it quite that much. So how do I go about stopping it from doing that?
 
I would start by not modifying a control in the Current event of a form. Find another means to achieve the results you want.
 
Any suggestions where else it may be suitable? That was the only place I could really think of :(
 

Users who are viewing this thread

Back
Top Bottom