DoCmd.openForm with goto???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rod4
    New Member
    • Jun 2015
    • 17

    DoCmd.openForm with goto???

    hello guys,

    i made a datasheet form with a selected number of fields. but you can doubleclick each record to go into the detailed record form. in the first two fields i put in this...

    Code:
    Private Sub Field1_DblClick(Cancel As Integer)
    
        DoCmd.OpenForm "Detailed Form", , , "[Tdate] = #" & [Tdate] & "#"
    
    End Sub
    that the form will be openend in exactly the correct record to show the detailed form. BUT this is a filter. so i cant cruise between the other records in the detailed form. is there any "docmd"-command which doesnt make a filter but opens just on the right record, so i can go up and down the records without the need of deleting the filter first?
  • jforbes
    Recognized Expert Top Contributor
    • Aug 2014
    • 1107

    #2
    The first example at https://msdn.microsoft.com/en-us/lib.../ff836583.aspx does what you are asking for. The one thing I would do different is instead of DoCmd.FindRecor d, I would use Bookmarks and .FindFirst kind of like what is done here: http://allenbrowne.com/ser-03.html

    Comment

    • rod4
      New Member
      • Jun 2015
      • 17

      #3
      I cant understand why i didnt find this "Openargs" myself! Thanks that you leed me the way. Here the Code i used to make it happen.

      Code:
      Private Sub Field1_DblClick(Cancel As Integer)
      
          DoCmd.OpenForm "Detailed Form", , , , , , [Tdate]
          
          Dim strTDate As Date
          strTDate = Forms![Detailed Form].OpenArgs
          If Len(strTDate) > 0 Then
              DoCmd.GoToControl "Tdate"
              DoCmd.FindRecord strTDate, , True, , True, , True
          End If
      
      End Sub
      I just put it in here to give others who google for it a nice and simple example!

      Comment

      Working...