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

docmd.findrecord

Status
Not open for further replies.

at51178

Technical User
Mar 25, 2002
587
0
0
US
Hey guys I am not sure what I am doing wrong or if this is the way to go
I created two text boxes text1 and text2
text1 is unbound
text2 is bound to table1
I would like to have the form look up information based on what I put in text1 so if I put in sugar
text2 will bring up sugar

but I would like the form to search anypart of the text so I used the docmd.findrecord let me know if I am on the right track with this one
dim field as string
field = "text2"
docmd.FindRecord,acEntire,field,acSearchAll,like,acAll
 
at51178,

Hey this will work if you want to set the search by Text2 the code will place the action of the search in the text2. However, I am not sure why you would want to type anything in text1 if it is already in text2. The setfocus will take care of it so if there is sugar in text2 and you look for sugar in the popup window then the data that has sugar in it first will open. Place this behind a button and name it find or you can change find to whatever you want but make sure find in code = the name you give button.

Private Sub find_Click()
On Error GoTo Err_find_Click

'Sets focus of search by text2 meaning anywhere on form it will search by text2.
Me![text2].SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_find_Click:
Exit Sub

Err_find_Click:
'MsgBox Err.Description
Resume Exit_find_Click

End Sub

Tofias1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top