Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display search record result in another form?

Status
Not open for further replies.

Gustavson

Technical User
Nov 2, 2001
105
US
I'm using Access 97.

I have a form which loads on startup. This form only serves the purpose of linking to parts on the database. Like a switchboard. Anyways, I want to add a search for record button on this form but I want the result to display on my main form. How do I set up this button so that it searches my records and displays the results on my main form in my database?

I assume there's a little code I need to add to this:

Private Sub Command37_Click()
On Error GoTo Err_Command37_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Command37_Click:
Exit Sub

Err_Command37_Click:
MsgBox Err.Description
Resume Exit_Command37_Click

End Sub

I guess I just need to tell the code where to look and where to display the results?

Hope this is enough info
Thanx
Gustavson
 
There's another thread [url="thread181-210546 trying to do the same thing, you certainly don't want to use all the Screen.Previous and menubar stuff. Use a recordset clone:

Dim frm as Form
Dim rst as Recordset
DoCmd.OpenForm "MyFrmNm"
Set frm = Forms!MyFrmNm
Set rst = frm.RecordsetClone
rst.FindFirst "KeyField = " & LookupValueFromSwitch
If Not rst.NoMatch then frm.Bookmark = rst.Bookmark
rst.Close
Set frm = Nothing
Set rst = Nothing

That's it. Remember to use "" if you're searching for strings, ## if you're searching for dates, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top