Refresh Form in Microsoft Access

R

Rekha

Hi,

I have an input form with a new button and submit button.

When I click on New button, I get a Run time error 2105, "Can't go to
the specified record. You may be at the end of the recordset". But the
recordset is not at the end. It shows me the form filled with already
existing record. It is not clearing the fields and not allowing me to
enter anything.

Please help me in this.

Thanks in advance..
Rekha

My code goes here...

Private Sub Form_Open(Cancel As Integer)
Forms!MPD!tbUser = gUser

If (Me.RecordsetClone.RecordCount > 0) Then
Forms!MPD.RecordsetClone.MoveLast
tbNumRecords.Value = Forms!MPD.RecordsetClone.RecordCount
Forms!MPD.RecordsetClone.MoveFirst
tbRecord.Value = Forms!MPD.CurrentRecord
End If

Me!ProjNum.Enabled = False

Forms!MPD.AllowAdditions = True

End Sub

Private Sub Form_AfterDelConfirm(Status As Integer)
tbRecord.Value = Me.CurrentRecord
tbNumRecords.Value = Me.RecordsetClone.RecordCount
End Sub

Private Sub Form_AfterInsert()
tbRecord.Value = Me.CurrentRecord
tbNumRecords.Value = Me.RecordsetClone.RecordCount
End Sub

Private Sub btnNewRequest_Click()
On Error GoTo Err_btnNewRequest_Click

DoCmd.GoToRecord , , acNewRec ' ----------> Error Message in this line

Exit_btnNewRequest_Click:
Exit Sub

Err_btnNewRequest_Click:
MsgBox Err.Description
Resume Exit_btnNewRequest_Click

End Sub
 
T

TC

I suggest placing:

msgbox me.allowadditions

immediately before the:

DoCmd.GoToRecord , , acNewRec

to confirm that AllowAdditions is actually true. Maybe you've
accidentally set it false, somewhere else in your code.

PS. Is MPD the name of this form? If so, why do you say Forms!MPD in
some places, and Me in others? You can always use Me to refer to the
current form.

HTH,
TC
 
R

Rekha

Msgbox gives the value True. Still it gives the same error. If
Me.AllowAdditions = True Then DoCmd.GoToRecord , , acNewRec

Still getting the same error. Please let me know what might be the
problem.
 
T

TC

First, if the form is bound to a query or a SELECT statement, make sure
that the query or SELECT statement is actally updatable! It might not
be. That would certainly explain your problem.

Second, check the Access "new record" button in the navigation buttons
at the bottom left of the form. If that button is enabled, you /should/
be able to add new records. If it /isn't/, you /shouldn't/. See if that
is consistent with what you are finding.

If all else fails, I'd take out all the code from your form module,
/except/ for your own "add new record" button. Use #IF FALSE THEN ...
#ENDIF brackets to disable all the rest of the code. If it still
happens, I'd be out of suggestions! If it doesn't, you know the problem
is so,mewhere in the disabled code.

HTH,
TC
(off for the day)
 
R

Rekha

Hi,

First method I tried giving full permissions to all the users to make
query updatable. It didnt work out for me.
Second, "new record" button is disabled. I am not able to make it
enabled.

How to do that? If I make that enabled, will I get rid of my problem?

Thanks
Rekha
 

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