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.
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.
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.
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
forms!OtherForm!InvoiceNo.
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
ASKER
You are both more elegant than me, and Trygve takes the points.
Excellent.
Excellent.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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