bound form does not add records

On my app I have  a form that pops up, aks for some data, computes, and should insert a new record in the DB. One of the things it does is to compute a new key, and the key is alright.
The situation is that the form is bound to a table, and on the properties is does allow only for "add records" (no Edits and no Deleets).
But in result is only editing the last record and never adding a new record,
Can anyone help?
João serras-pereiraAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

João serras-pereiraAuthor Commented:
a post scrimptum. The full code is below:


Private Sub btn_sairNovoExame_Click()

On Error GoTo errorTrap

    Call logMe("btn_sairNovoExame_Click", "start")
    If IsNull(Me.frm_MotivoExame) Then
        MsgBox "Motivo de Exame não preenchido"
    End If
    If IsNull(Me.frm_dataExame) Then
        MsgBox "Data de Exame não preenchida"
    End If
    Me.frm_idExame = Forms![_intData].frm_exameRecCount
    Forms![_intData].frm_exameSalvo = True
    Forms("frmPaciente").frmExameLista.Requery

    If Me.Dirty = True Then
        Me.Dirty = False
    End If
    Call logMe("btn_sairNovoExame_Click", "end")
    DoCmd.Close acForm, "frmExameNovo"
    Exit Sub
    
errorTrap:
    MsgBox "[btn_sairNovoExame_Click]." & "[" & Err.Number & "].[" & Err.Description & "]"
    Call logMe("btn_sairNovoExame_Click", "errorTrap:" & "[btn_sairNovoExame_Click]." & "[" & Err.Number & "].[" & Err.Description & "]")
    Resume Next
    
End Sub

Open in new window

0
João serras-pereiraAuthor Commented:
will be the "Data Entry" flag?


Screen-Shot-2018-02-13-at-16.18.37.png
0
Gustav BrockCIOCommented:
Nowhere seem you to goto a new record or calling rs.AddNew.
Without that, you will be editing the current record (which you can't).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

João serras-pereiraAuthor Commented:
ha! Ok I thought that when the form is bound I should not use rs.addnew
I am pasting it back (the form was unboud before...)
0
João serras-pereiraAuthor Commented:
or can I use:
DoCmd.GoToRecord , , acNext ?
0
PatHartmanCommented:
When you use the OpenForm method, one of the options is to open in Add mode.  If you do that, the form will open to a new record.  NO CODE required.  No need to permanently set the Data Entry property to yes.

PS - That isn't even close to being the full code.
1. We don't know what form is running the code
2. You didn't post the LogMe function.
3. You don't seem to have any code in the form's BeforeUpdate event so you are not properly validating the new record.
0
Gustav BrockCIOCommented:
acNewRec it will be.
0
João serras-pereiraAuthor Commented:
Hi.
It runs (well close as now it always create a blank record :()

and Patwas right - it was not the full code, but (currently) almost all. I have just a bit of preparing code on the "on load" event" but it is unrelated - well it was. Now I have  the DoCmd.GoToRecord , , acNewRec  there and that's why I always getting a blank record.
... I'll find a way out...
0
João serras-pereiraAuthor Commented:
well ... sigh
I need to reopon the case. It's not working again!
0
Gustav BrockCIOCommented:
Perhaps it is time for a relaxing moment doing something else.
0
João serras-pereiraAuthor Commented:
I did!
tomorrow is another day!
0
PatHartmanCommented:
Now I have  the DoCmd.GoToRecord , , acNewRec  there and that's why I always getting a blank record.
... I'll find a way out...
Change the way you are opening the form and you won't have to force it to go to a new record.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.