Form saves data, but does NOT display or update

V

vegathena

I am working with an adp with a SQL Server backend.

I have a bound form that contains the id in the form header. The
detail section contains several fields. This form saves a new record
just fine. The problem is that when I try open the form for an
existing record (by id), the form displays blank. When I go ahead and
re-enter data into those fields and try to save, I get a "Violation of
Primary Key constraint; cannot insert duplicate key"

This form has a Form_Current sub that checks for a NewRecord.
NewRecord always shows 'true' even when the record already exists.

Here is the code that opens this form:
DoCmd.OpenForm "frmTest", , , "id=" & Global_id, acFormEdit, ,
Me.OpenArgs

Here is the form code:
Private Sub Form_Current()
If Me.NewRecord Then
Me.txtid = Global_id
End If
End Sub

This form has the following properties:
Record Source: test_table
Allow filters: No
Data Entry: No
Recordset Type: Updatable Snapshot
Cycle: Current Record

I need this form to not only save data, but also to display and update
data for a given record. I appreciate any help you can give in this
matter!
 
D

Douglas J. Steele

Try removing the acFormEdit from the command. I think that overrides the
form's DataEntry property, and sets it to True.
 
V

vegathena

Doug, I removed acFormEdit as you suggested, but the form still
doesn't display the given record. Also, I continue to get the primary
key constraint violation error.

Any other ideas what could be wrong?
 
B

Bob Quintal

(e-mail address removed) wrote in
:
Doug, I removed acFormEdit as you suggested, but the form still
doesn't display the given record. Also, I continue to get the
primary key constraint violation error.

Any other ideas what could be wrong?
Is the form's data entry property set to yes?
 

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