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

Quirk in link criteria when opening a sub-form record

Status
Not open for further replies.

Najemikon

Technical User
Mar 5, 2002
168
GB
Hi,

This is a small niggle of a problem that I thought I may as well ask about, rather than just keep putting up with it.

In my forms, I use the following line quite a bit. Often in the Not In List property of a combo box or more simply, a command button to create a new record in another table:

DoCmd.OpenForm "SecondForm", , , , acFormAdd

I then follow it up with lines to automatically fill data:

Forms!SecondForm.CreatedBy = [CurrentUser]
Forms!SecondForm.CreatedWhen = Now()

It works ok most of the time, but sometimes (very random!)it doesn't add a new record. Instead it opens the first record of the table SecondForm is attached to. Then my autofill lines happily overwrite existing data! I've no idea why it does this. If I click the button again without restarting or any other error checking, it works.

As in other parts of the database, I could write a new record direct to the table via a RecordSet, so I suppose I could create the record, then use link criteria to open it in the subform. But that feels like a long winded bodge that won't teach me why it happened!

If it helps to know, the DB is split, so the tables are in a backend.


Cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top