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

  • Thread starter Thread starter Bill (Unique as my name)
  • Start date 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.
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top