Saving New Record

J

JamesJ

I need to requery a form and the form's list box to reflect a new record.
I tried the following:
Me.Requery
Me!lstDvd.Requery
in the BeforeUpdate and the AfterUpdate and I keep
getting an error (2115).
I'll try to remember.
The Macro or Function set to the BeforeUpdate or Validation rule is
preventing
MyDb to saving the data in the field.
(It would be nice to be able to copy and paste error messages.)

The form consists of a Listbox - lstDvd which has only one row visible -
DvdMovieTitle.
The form contains the other pertinent fields to edit or add data.

Any help will be appreciated.
James
 
S

strive4peace

Hi James,

check your table design -- make sure that Text fields have
Required --> false

Also, check any validation rules you have set up for each field.

If you have any foreign keys that may not be filled out,
make sure the DefaultValue is not 0 as 0 will not probably
match up to the related key in the main table. Set
DefaultValue --> =null

On requerying the listbox: just use
Me.lstDvd.Requery

depending on your SQL, the record may first need to be saved:
if me.dirty then me.dirty = false

Warm Regards,
Crystal
MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 
J

JamesJ

There are only 4 fields here.: DvdMovieID (AutoNumber), DvdMovieTypeID,
DvdMovieTitle and DvdSynopsis.
None are required and none have a default value of 0.
This occurs after I enter data for a new record and then move to
another row in the listbox. The error occurs at Me.Requery.

James
 
S

strive4peace

Hi James,

I have run across this error when I am using a
listbox/combobox that gets its criteria from a control on
the form.

The solution is to replace the RowSource of the listbox with
an SQL statement where the criteria is specified in the SQL
instead of being a reference to a form control.

If you need help with this, paste the SQL for your listbox.
You can choose View, SQL from the menu.

Sorry it has taken so long to get back to you, I have been
out of town.

Warm Regards,
Crystal
MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 
S

strive4peace

Hi James

had another thought -- what code is your listbox processing?
Is it changing to another record? If so, something to add
before you issue commands to move is:

'Save the record
if me.dirty then me.dirty = false


Warm Regards,
Crystal
MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top