find and goto record

D

David Whitaker

I am wanting to create my own popup that will kinda act as a search and goto
dialog.
I am wanting to find and go to a specific record based on 2 comboboxes
values that are seleted

combo1 would have the date
combo2 would have a name

I can fiqure out how to do everything except for how do you take the values
from both of the comboboxes from the popup and find an existing record on an
open form and goto it?

hope this is not confusing!
 
D

Dale Fye

David,

In your pop-up form, you will need to create a recordset that is a clone of
your first form, then use the findFirst method to locate the matching
record, then use the bookmark property of the main form and your recordset
to move to the matching record on the main form. I've never done this with
a pop-up before, but it works when you actually put it on the main form, so
it should work just as well when run from a pop-up.

The following is untested, but should give you an idea. It assumes that the
values in combo1 and combo2 of your pop-up form are string values. If they
are not, then get rid of the references to chr$(34), which is the quotation
mark (").

Private Sub cmd_FindRecord_Click()

Dim rs as dao.recordset
Dim strCriteria
Set rs = FORM_YourFormName.Recordsetclone

strCriteria = "Field1 = " & chr$(34) & me.combo1 & chr$(34) & " AND " _
& "Field2 = " & chr$(34) & me.combo2 & chr$(34)

With rs
.FindFirst strCriteria
if .nomatch then
msgbox "No matching record found"
else
FORM_YourFormName.BookMark = rs.bookmark
endif
end with
rs.close
set rs = nothing

End sub

HTH
Dale
 

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

Top