?
Solved

DoCmd.GoToRecord SYNTAX

Posted on 2014-11-17
4
Medium Priority
?
779 Views
Last Modified: 2014-12-05
Hello ~ I'm attempting to go to a specific record on an open form using:
DoCmd.GoToRecord acDataForm, "frmProject", , "projID =" & ProjLINK

I receive: Run-time error 2498
ProjLINK is an integer
projID  is an auto-number ID and the primary key reflected on frmProject

Clearly I'm missing something here.
Would appreciate illumination!

Many Thanks!
0
Comment
Question by:Chi Is Current
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 75
ID: 40449142
You might try this:

docmd.GoToRecord acDataForm, "frmProject",acGoTo, "[projID] =" & CLng(me![ProjLINK])


Where is ProjLINK located ?  A field or text box on the Form ?
mx
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 40449483
GoToRecord is just for moving up/down the records.

For searching use:

DoCmd.SearchForRecord, "frmProject", acFirst, "projID = " & ProjLINK & ""

/gustav
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 2000 total points
ID: 40455772
In Access 2003, there is no SearchForRecord, there is DoCmd.FindRecord
With many records, that becomes BRUTALLY slow.

These days, I'd use
Dim db As Database
Dim rst As DAO.Recordset
Dim strCriteria As String
Dim TheprojID as Long
strCriteria = "projID = " & ProjLINK
    
'finding no match takes forever so
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT projID from WhatEverTable where " & strCriteria & ";", dbOpenDynaset, dbSeeChanges)
If rst.RecordCount = 0 Then
    response = MsgBox("No such projID found.", vbInformation)
Else
    TheprojID = rst!projID
    rst.Close
    strCriteria = "projID  = " & TheJobID
    Set rst = Me.RecordsetClone
    rst.MoveLast
    rst.FindLast strCriteria
    Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing

Open in new window


It performs an order of magnitude faster than DoCmd.FindRecord once you start going north of 10K records
0
 
LVL 2

Author Comment

by:Chi Is Current
ID: 40484320
Hello mx, /gustav & Nick67, thank you ALL for your thoughtful replies.
I am most grateful for your ideas and expertise.

Seems this is not really as much of a syntax question as a strategy question.

I think the best way of displaying the desired record is by using Nick67's method:
    ...
    rst.FindLast strCriteria
    Me.Bookmark = rst.Bookmark

Gotta give Nick67 the points for pure psychic accuracy,
this solution is perfect.

Thank you ~ Jacob
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question