Find A Date In A Date Field On A Subform Using VBA

  • Thread starter Bill (Unique as my name)
  • Start date
B

Bill (Unique as my name)

I have a form with a datasheet subform. I want to enter a date in an
unbound control in the main form and execute a private sub to find the
date in the subform. The name of the unbound control is "Jake". The
name of the subform is "Arleen". The name of the date field in the
subform is "Hillary". (Hey, I like names more colorful than t369.)

Could someone please help me? Thank you in advance.
 
M

Marshall Barton

Bill said:
I have a form with a datasheet subform. I want to enter a date in an
unbound control in the main form and execute a private sub to find the
date in the subform. The name of the unbound control is "Jake". The
name of the subform is "Arleen". The name of the date field in the
subform is "Hillary". (Hey, I like names more colorful than t369.)


Well, you are using a unique naming convention ;-)
but those name convey no meaning to anyone than yourself.
Think about what you are doing to your successor ;-))

You can use Jake's AfterUpdate event or create a button to
run code to bring the record with the matching date into
view:

With Arleen.Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Hillary = " & Format(Jake, "\#m\/d\/yyyy\#")
If Not .NoMatch Then
Arleen.Form.Bookmark = .Bookmark
End If
End If
End With
 
B

Bill (Unique as my name)

Wow! It worked perfectly, Marshall. Thank you!

Marshall said:
Well, you are using a unique naming convention ;-)
but those name convey no meaning to anyone than yourself.
Think about what you are doing to your successor ;-))

You can use Jake's AfterUpdate event or create a button to
run code to bring the record with the matching date into
view:

With Arleen.Form.RecordsetClone
If .RecordCount > 0 Then
.FindFirst "Hillary = " & Format(Jake, "\#m\/d\/yyyy\#")
If Not .NoMatch Then
Arleen.Form.Bookmark = .Bookmark
End If
End If
End With
 
Top