Pop up - create duplicate value error

B

Bonnie

Hi,

I have a pop up form from the main form to key some additional info in the
same field that's on the screen in the main form. I have filtered it for the
secondary form incident no to match the main form incident no - when I try to
save the record in the pop up form I get an error - changes I requested would
create duplicate value - can't save.

Can anyone help?

Thanks,

Bonnie
 
J

John W. Vinson

Hi,

I have a pop up form from the main form to key some additional info in the
same field that's on the screen in the main form. I have filtered it for the
secondary form incident no to match the main form incident no - when I try to
save the record in the pop up form I get an error - changes I requested would
create duplicate value - can't save.

Can anyone help?

Not without knowing more about your database, no. It appears that your popup
form is creating a new record rather than editing an existing one; even
editing an existing record would be problematic if you're trying to edit the
same record from two different forms simultaneously.

Why a subform, rather than a scrollbar in the textbox? Or use Shift-F2 to open
a Zoom box if you just don't have room in the textbox for more text? Or use a
Tab Control and a larger textbox?


John W. Vinson [MVP]
 
B

Bonnie

Thanks for responding John. I did figure it out - I have a subform on the
popup form that had a key field that I was trying to add multiple records
too. Sorry mia culpa. I will check into that ZoomBox - don't even know what
it is.

Thanks!
 
B

Bonnie

Thought of another way, what do you thinK:

From the second form, save the data to variables (I guess unbound text
boxes) and populate fields on first form with the variables and then close
the second form.

Bonnie
 
P

Pat Hartman

I agree with John, it is best to avoid this method. However, if you do it,
be sure to save the current record if it is dirty before you open the popup.
that will avoid conflicts from having the same record dirty in two places.
 
B

Bonnie

Thanks for responding.

So what is the VBA syntax to save the record? Me.save

Thanks,

Bonnie
 
J

John W. Vinson

Thought of another way, what do you thinK:

From the second form, save the data to variables (I guess unbound text
boxes) and populate fields on first form with the variables and then close
the second form.

Too complicated.

Instead, open the second form in dialog view from the click event of a form
button (or some other event as appropriate). Make the second form unbound. The
click event code will halt when the form opens since it's in dialog mode.

Put a Close button on the second form which does not actually close the form
but sets its Visible property to false. Either closing *or hiding* the form
will let the calling code resume. You can then pull values from the (invisible
but still open) form controls and push them into your main form's controls.

This entire exercise SHOULD NOT BE NECESSARY though; if you're only doing it
because of screen space utilization... redesign your form, to use tab
controls, scrollbars, zoom on got focus, etc. rather than the major overhead
of a second form.


John W. Vinson [MVP]
 
J

John W. Vinson

So what is the VBA syntax to save the record? Me.save

Confusingly, that doesn't save the record - it saves *design changes to the
structure of the form* and therefore is only available in design mode. Instead
use either

DoCmd.RunCommand acCmdSaveRecord

or

If Me.Dirty Then Me.Dirty = False

John W. Vinson [MVP]
 
H

hughess7

Hi, I need to do a similar thing. Basically we audit claims and if we find
any discepancies we have to raise an Issue. Each issue may require additional
information to be collected by the end user relating to the claim, for
example if the Repair Date is incorrect we have to capture the incorrect date
etc.

Some issues require the same data to be captured. For example I need the 2nd
form to show the Repair Date if it has already been captured by the end user,
or blank if not to be entered.

The way I have tacked this is to have lots of forms (one per issue that
requires additional data), but rather than have them all as subforms I want
them to act as a popup to prompt the user for the data. I know I could have
them all as subforms and hide/unhide them as necessary but there are a lot of
them so positioning would be an issue and also I want it to be obvious to the
end user exactly what they have to fill out. For example if Issue 9600 is
selected the end user has to enter the diary date and repair date (if not
already captured against a different issue). I have designed all the forms,
each one is named the same as the Issue Code used so it can be triggered via
code. Each one has all the relevant fields displayed...

It is just how to link this back to the main form if it isn't a subform. You
can't have subforms as pop-ups can you?

Thanks in advance for any help.
Sue
 

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