Link to home
Start Free TrialLog in
Avatar of englishman
englishman

asked on

GoToRecord command

I am jumping from one form to another using:

    DoCmd.GoToRecord acDataForm, "ViewInvoices", acGoTo, 2

but instead of going to record number 2 I want to go to the same record that I am already in. acNext  - ok,  acPrevious - ok ... but I want to go to the very same record.
What is this command?!!!

Cheers.

Avatar of smilitaru
smilitaru
Flag of Romania image

Please, be less confusing.
If you don't know to go from current record you have no need to use GoToRecord command, or if You want to use try with
DoCmd.GoToRecord acDataForm, "ViewInvoices", acGoTo, 0
Avatar of englishman
englishman

ASKER

DoCmd.GoToRecord acDataForm, "ViewInvoices", acGoTo, 0
0 is an invalid value.

I was using:

    Dim stLinkCriteria As String

    stDocName = "ViewInvoices"
   
    stLinkCriteria = "[InvoiceNo]=" & Me![InvoiceNo]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

But the trouble with this is that it filters the records.
You need to use 'Bookmark' property of the Form record source.
Or:
forms!OtherForm!InvoiceNo.setfocus
DoCmd.FindRecord me!InvoiceNo

The bookmark approach is more elegant (even if it takes more code to do it), but often considered a bit confusing by non-expert programmers
You are both more elegant than me, and Trygve takes the points.
Excellent.
ASKER CERTIFIED SOLUTION
Avatar of Trygve
Trygve

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial