Error with GoToRecord

gsforfree

New Member
Joined
Jun 9, 2005
Messages
44
Hi,

When I run

Public Sub getRecord(recNum)
On Error GoTo Err_getRecord

DoCmd.GoToRecord , , acGoTo, recNum

Exit_getRecord:
Exit Sub

Err_getRecord:
MsgBox Err.Description
Resume Exit_getRecord

End Sub

in the specified form code window, I receive an error that states "You cannot go to the specified record." It seems that the syntax is correct, is there a setting on the form I'm missing?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi

From the Access/VBA help :
When the Record argument is Go To, Access moves to the record with the number equal to the Offset argument. The record number is shown in the record number box at the bottom of the window.

Is the value in recNum larger than the number of records in the table / form? Can you move away from the current record once it is saved? (i.e. is it a referential integrity problem?) If not can you explain what you want to achieve?

Andrew :)
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,334
Members
449,077
Latest member
Jocksteriom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top