Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713

    Unanswered: GoToRecord in a subform ... Access 2000

    Hi all ...

    Dilemma: I have a subform that I add records to using ADO ... No problem there. The problem I'm having is after adding the record in question I want to have that record selected within the subform. Since I have to issue a Requery call to the subform in order for that new record to "appear" (which also sets the record pointer back to the 1st record in the list), I'm trying to issue a DoCmd.GotoRecord call which does not seem to work ... Ex:

    DoCmd.GoToRecord acDataForm, "Account Records", acLast

    Any ideas on what I'm missing?

    Answers to your questions:

    No. The subform is not ordered. When adding, the record is the last one. I know what the record # is ...

    I've also tried the ", acGoTo, XXX" option also ...

    I have a suspicion that the "form name" may be what is tripping me up ... My example has the proper form name of the subform.

    Thanks!

    - Mike
    Back to Access ... ADO is not the way to go for speed ...

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Okay ... And here's the code for my add:
    Code:
    Private Sub AddAcctButton_Click()
        On Error Resume Next
        
        If AvailableAccountsList.ItemsSelected.Count < 1 Then Exit Sub
        
        EditingAccountID = AvailableAccountsList.Column(0, AvailableAccountsList.ListIndex)
        SQLString = "INSERT INTO " & ExistingAcctsTbl & " (ContactID, AccountID, [Account Number], Active, ContactNdx, Updated, Deleted) VALUES ("
        SQLString = SQLString & CurrentContactID & ", "
        SQLString = SQLString & EditingAccountID & ", '"
        SQLString = SQLString & AvailableAccountsList.Column(1, AvailableAccountsList.ListIndex) & "', "
        SQLString = SQLString & AvailableAccountsList.Column(2, AvailableAccountsList.ListIndex) & ", "
        SQLString = SQLString & ContactNdx & ", True, False);"
        CurrentProject.Connection.Execute SQLString, , adCmdText
        
        SQLString = "UPDATE " & AvailableAcctsTbl & " SET IsVisible=False WHERE (AccountID=" & EditingAccountID & ");"
        CurrentProject.Connection.Execute SQLString, , adCmdText
        
        LoadingDelay
        Me![ExistingAccountsList].Requery
        AvailableAccountsList.Requery
        
        ExistingAcctCount = ExistingAcctCount + 1
    MsgBox " # of accts: " & ExistingAcctCount
        DoCmd.GoToRecord acDataForm, "Account Records", acLast
    '    DoCmd.GoToRecord acDataForm, "Account Records", acGoTo, ExistingAcctCount
        'Me![ExistingAccountsList].Form.GoToRecord
       
    End Sub
    P.S. LoadingDelay is a 5 sec loop delay ...
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    GOT IT!

    Just had to set the focus to the subform control and issue:

    DoCmd.GoToRecord ,,acLast

    ... And bingo.
    Back to Access ... ADO is not the way to go for speed ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •