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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro Problem.....PLEASE HELP !!!!

Status
Not open for further replies.
Jul 17, 2001
19
US
Im trying to setup a form that has a blank text box with a search button next to it. I want to be able to type a search string into the text box, and then be able to click on the search button and have it search a table. If ANYONE knows what I need to do, PLEASE let me know.
 
marksparro,

i'm kinda new at this, but i'll try to help. on the afterupdate section of your text box you can insert a macro that queries the appropriate table for corresponding information. you can choose openquery and specify the info, you can drag the query into the macro from the query section, or you can pick runSQL and create an SQL statement that searches for what you want. try this and let me know. you shouldn't need the command button.
 
if the table is the RecordSource for the Form you can use
FindFirst with Me.RecordsetClone

With Me.RecordsetClone
.FindFirst "[LastName] = '" & TextBoxName & "'"
If .NoMatch Then
MsgBox "No Matching Record for Data Entered"
Else
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
End With

if the table is not the RecordSource you can use DLookUp

ReturnData = DLookup("[Title]", "employees", "[LastName] = '" & TextBoxName & "'")

or you can open a form that is filtered on that value entered

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmEmployees"

stLinkCriteria = "[LastName]=" & "'" & Me![TextBoxName] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Hope this Helps

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top