Default Value - Save the record!

enfinity

Registered User.
Local time
Today, 12:34
Joined
May 31, 2007
Messages
35
Hi there,

I have a form that I want to be opened and insert one new record into the table. When the form loads, the following happens:

1) Create new record
2) Put a default value into a control element (bound text box)

My problem is that Access does not save the record to the underlying table + it does not create the pk value (auto inc).

When I click into the text box and enter the default value again & hit enter, the record is saved. Any idea how I can save the record without doing that?

Thanks!
Steve
 
Are you really sure you want to be creating a default blank record based on purely default entries every time a form loads?
What's the holistic reasoning behind this? Is it so that some child records (perhaps in a subform) have a parent? You could always make sure of that in other ways.

In principal - to Dirty a form via code - the focus must be on a control which can be updated. You can then Dirty and unDirty the form via code too. The record will be saved as long as all required field vaues are present. Otherwise you'll get a runtime error.
If you don't want to save the record - but only dirty to display the autonumber then Dirtying alone is enough of course.
 
The reason I want to do it is pretty simple: The default value is based on a control element in the parent form so every time the form is loaded, the control element should display this value. My problem is that Access does not save the record unless I click in the field and type in the same value again.

I enclosed a screenshot of the form. As you can see, the auto inc field "Rechnungsnummer" is empty. The pk fields for the underlying table both show default values. I also included a save button with runs a macro to save the record. However, it does not work until I click in the "Projekt" field, enter the value again and hit enter.

Any idea how I can solve this problem?

BTW: I have a hard time understanding what you mean by "dirtying" ;)
 

Attachments

  • sample.jpg
    sample.jpg
    39.6 KB · Views: 170

Users who are viewing this thread

Back
Top Bottom