Search macros in forms

Axel

New member
Local time
Today, 15:41
Joined
Mar 8, 2007
Messages
1
hey,

I'm trying to build a database for my music collection. Because of this I think it would be handy if I could write a macro in forms to let a search box pop up.

Does anybody have any idea how to do this since my knowledge of VBA and macros is quite limited.

Thanks in advance:)
 
Add a button to your form called search. In the onclick event of that button, put in the following vba code: docmd.openform "frmSearch"

Replace frmSearch with the name of your search form. I often use pull down lists for searching by key fields. Once they pick a value from the list, you can set the record for the form like so:

Code:
Dim frm As Form
    Set frm = Forms![MusicMaster]
    frm.RecordsetClone.FindFirst "[SongID] = '" & Me![SongID] & "'"
    frm.Bookmark = frm.RecordsetClone.Bookmark
    frm.Refresh
    DoCmd.Close acForm, "frmSearch"

John M Reynolds
 

Users who are viewing this thread

Back
Top Bottom