You cant go to specified record

G

Guest

I have a form with an Add Record button.
When the button is clicked when first entering the form, I works great.
When the 1st record is entered and the button is clicked again to enter
another record, I get a msg "You cant go to specified record." I click the
OK button and then...
I am able to click the Add Record button and it works.

Any suggestions?
 
G

Guest

Do you have the DataEntry set to = Yes

If so, change it to = No

Note this will stop you entering the form at a new record. To continue
entering the form at a new record you would need to add some code to the
form's OnLoad event

Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub


Hope this helps, good luck
 
G

Guest

Data entry is set to No

Tried..
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub

didn't help

I even put Me.AllowEdits = True
Me.AllowAdditions = True in the code.

It's making me crazy...
 
G

Guest

Private Sub btnAddNew_Click()
On Error GoTo Err_btnAddNew_Click

Me.AllowEdits = True
Me.AllowAdditions = True

ProjID.SetFocus

DoCmd.SetWarnings False
' if current record report date is 1 then delete
If Me.ReportDtID = 1 Then
Me![Photo] = "none"
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
DoCmd.SetWarnings True

DoCmd.GoToRecord , , acNewRec

Exit_btnAddNew_Click:
Exit Sub

Err_btnAddNew_Click:
MsgBox Err.Description
Resume Exit_btnAddNew_Click
 
G

Guest

Hi

Sorry for not getting back to you sooner.

I noticed that you are adding and deleteing the new reocrd at the same time
so you will never be able to go to it unless you cancel the operation ??
(which is what seem to be happening.
If Me.ReportDtID = 1 Then
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
DoCmd.GoToRecord , , acNewRec

eg. If something abc then delete - then add a new XXX

Also
I don't really understand all this
If Me.ReportDtID = 1 Then
Me![Photo] = "none"
Me![Page] = 999999999
Me.Undo

Especially this
Me.Undo

But as I can' see your DB you know best ?

I would step through the code o see what is doing the mischeaf. Like this

Cut out all the bits you don't really need like this

Private Sub btnAddNew_Click()

ProjID.SetFocus

If Me.ReportDtID = 1 Then
Me![Photo] = "none"
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Else
DoCmd.GoToRecord , , acNewRec
End If
End Sub

Then see if this makes things OK. If not then cut out line by line. You
never know.



Hope this helps


--
Wayne
Manchester, England.



deb said:
Private Sub btnAddNew_Click()
On Error GoTo Err_btnAddNew_Click

Me.AllowEdits = True
Me.AllowAdditions = True

ProjID.SetFocus

DoCmd.SetWarnings False
' if current record report date is 1 then delete
If Me.ReportDtID = 1 Then
Me![Photo] = "none"
Me![Page] = 999999999
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
DoCmd.SetWarnings True

DoCmd.GoToRecord , , acNewRec

Exit_btnAddNew_Click:
Exit Sub

Err_btnAddNew_Click:
MsgBox Err.Description
Resume Exit_btnAddNew_Click
--
deb


Wayne-I-M said:
Can you post the code behind the button you use to add new records
 

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