GoToRecord function doesn't work on 2nd click

T

Tom

I have an unbound textbox and a command button "GoToRecord" on a form.

When I enter an AutoNumber RecordID (e.g. "50") into the unbound textbox and
then click "GoToRecord", I move to the particular record... works great thus
far.

However, once I made a change on record "50" and then enter "100" in the
unbound text and click "GoToRecord" again, nothing happens (I remain on 50
vs. jumping to 100).

Well, I actually get the following 2 dialog boxes (errors):

First: "Update or CancelUpdate without AddNew or Edit."
Then: "You can't save record at this time. Yes or No"



Does anyone how I can adjust the function below so that I can do the
following:
- enter 50
- click GoTo... I jump to record 50
- make a change on record 50
- I enter 100
- click GoTo... I jump to record 100
- and so on...


Thanks,
Tom


Here's my current function:
===========================

Private Sub GoToRecord_Click()

If Me.RecordID.Value <> "" Then
Me.RecordID.Enabled = True
Me.RecordsetClone.FindFirst "[RecordID]=" & Me!FindRecordID
If Not Me.RecordsetClone.NoMatch Then Me.Bookmark =
Me.RecordsetClone.Bookmark
Else
Me.RecordID.Enabled = False
End If

'Takes focus off command button
Me.cboDivision.SetFocus

'Reset properties for finding records
Me.FindRecordID.Value = ""
Me.GoToRecord.Enabled = False

End Sub
 
T

t t via AccessMonster.com

you can go to the record which you want wiht the codes

Dim RECNUM
RECNUM = Val([Text1])
DoCmd.GoToRecord , , acFirst
DoCmd.GoToRecord , , RECNUM

you have to go the firs record on each click because docmd goes to the
record current record number + text1 value.

example
think you are at firs record and your textbox includes 25
thend docmd.gotorecod goes to 26th record

if you click command button again with out goto first record line then it
will go to the 51st record

using that line if your text box value is 25 then goto record will go 25th
record.

if value is 100 then it will go to the 100th record.

I hope this will help you...
 
M

Marshall Barton

Tom said:
I have an unbound textbox and a command button "GoToRecord" on a form.

When I enter an AutoNumber RecordID (e.g. "50") into the unbound textbox and
then click "GoToRecord", I move to the particular record... works great thus
far.

However, once I made a change on record "50" and then enter "100" in the
unbound text and click "GoToRecord" again, nothing happens (I remain on 50
vs. jumping to 100).

Well, I actually get the following 2 dialog boxes (errors):

First: "Update or CancelUpdate without AddNew or Edit."
Then: "You can't save record at this time. Yes or No"



Does anyone how I can adjust the function below so that I can do the
following:
- enter 50
- click GoTo... I jump to record 50
- make a change on record 50
- I enter 100
- click GoTo... I jump to record 100
- and so on...


Here's my current function:
===========================

Private Sub GoToRecord_Click()

If Me.RecordID.Value <> "" Then
Me.RecordID.Enabled = True
Me.RecordsetClone.FindFirst "[RecordID]=" & Me!FindRecordID
If Not Me.RecordsetClone.NoMatch Then Me.Bookmark =
Me.RecordsetClone.Bookmark
Else
Me.RecordID.Enabled = False
End If

'Takes focus off command button
Me.cboDivision.SetFocus

'Reset properties for finding records
Me.FindRecordID.Value = ""
Me.GoToRecord.Enabled = False

End Sub


I think the problem may be that you need to save the record
you've been editing before going to a different record. Try
adding:
DoCmd.RunCommand acCmdSaveRecord
or, preferably:
If Me.Dirty Then Me.Dirty = False
right before the FindFirst line.
 
T

Tom

DoCmd.RunCommand acCmdSaveRecord

works perfectly.

Thanks,
tom


Marshall Barton said:
Tom said:
I have an unbound textbox and a command button "GoToRecord" on a form.

When I enter an AutoNumber RecordID (e.g. "50") into the unbound textbox and
then click "GoToRecord", I move to the particular record... works great thus
far.

However, once I made a change on record "50" and then enter "100" in the
unbound text and click "GoToRecord" again, nothing happens (I remain on 50
vs. jumping to 100).

Well, I actually get the following 2 dialog boxes (errors):

First: "Update or CancelUpdate without AddNew or Edit."
Then: "You can't save record at this time. Yes or No"



Does anyone how I can adjust the function below so that I can do the
following:
- enter 50
- click GoTo... I jump to record 50
- make a change on record 50
- I enter 100
- click GoTo... I jump to record 100
- and so on...


Here's my current function:
===========================

Private Sub GoToRecord_Click()

If Me.RecordID.Value <> "" Then
Me.RecordID.Enabled = True
Me.RecordsetClone.FindFirst "[RecordID]=" & Me!FindRecordID
If Not Me.RecordsetClone.NoMatch Then Me.Bookmark =
Me.RecordsetClone.Bookmark
Else
Me.RecordID.Enabled = False
End If

'Takes focus off command button
Me.cboDivision.SetFocus

'Reset properties for finding records
Me.FindRecordID.Value = ""
Me.GoToRecord.Enabled = False

End Sub


I think the problem may be that you need to save the record
you've been editing before going to a different record. Try
adding:
DoCmd.RunCommand acCmdSaveRecord
or, preferably:
If Me.Dirty Then Me.Dirty = False
right before the FindFirst line.
 

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