Results 1 to 5 of 5
  1. #1
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150

    Go to certain record on continuous form

    I have a continuous form that has checkbox of a field that is true/false. The data is based on a joined query, so when the user double clicks on the checkbox, it will change status, then the form is requeried. However, when the form requeried, the record is elsewhere. Can't I use the goto record so that when the form is requeried, the form can go to the record the user was on? Below line doesn't seem to work.

    Code:
    DoCmd.GoToRecord acDataForm, "frmMyForm", acGoTo, "CustomerID= " & "'" & strCustomerID & "'"
    I get the "An expression you entered is the wrong data type for one of the arguments" CustomerID is a string type, so I don't think it's the syntax, but I can be wrong.

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Try DoCmd.GoToRecord acDataForm, "frmMyForm", acGoTo, "CustomerID= '" & strCustomerID & "'" or better use the bookmark and recordset method (look at the code the Access wizard uses when you create a combo-box to navigate to a certain record).

    Cheers,
    Vlad

  3. #3
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    A requery of the form will cause it to go to the first record.
    So before the requery, you need to save the current customerID (in strSaveCustomerID) so that you know what record to return to.
    Code:
    Forms("frmMyForm").Recordset.FindFirst "CustomerID='" & strSaveCustomerID & "'"

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    As already stated, a requery causes the form to go to the first record.
    However, if this is being done after a field has been updated, try using DoCmd.Recalc instead of DoCmd.Requery
    The form will be updated but it stays on the same record
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150
    Quote Originally Posted by davegri View Post
    A requery of the form will cause it to go to the first record.
    So before the requery, you need to save the current customerID (in strSaveCustomerID) so that you know what record to return to.
    Code:
    Forms("frmMyForm").Recordset.FindFirst "CustomerID='" & strSaveCustomerID & "'"
    Great. The .FindFirst method works great. Thanks.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 02-26-2018, 05:21 AM
  2. Moving to record on a continuous sub-form
    By tonez90 in forum Access
    Replies: 4
    Last Post: 09-11-2017, 04:46 PM
  3. Replies: 3
    Last Post: 10-12-2012, 01:38 PM
  4. Delete continuous form record
    By tylerg11 in forum Forms
    Replies: 3
    Last Post: 03-09-2012, 03:00 PM
  5. Get position of record in continuous form
    By Whizbang in forum Forms
    Replies: 3
    Last Post: 11-02-2011, 01:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums