Search button to search subform

trish

really crap at access
Local time
Today, 05:11
Joined
Apr 24, 2001
Messages
19
Hello

I have a main form with a search command button in the header. This search facility looks for information in a subform. At the moment I can't seem to get it to work.

Main form called Building
Subform called LineTypeSub
Field its trying to search is called Line

Here's the code I have at the moment.

Private Sub cmdSearchLine_Click()

DoCmd.ShowAllRecords
DoCmd.GoToControl ("Line")
DoCmd.FindRecord Me!SearchLine

Line.SetFocus
SearchLine = Line.Text
SearchLine.SetFocus
strSearch = SearchLine.Text
End Sub

If anyone could help that would be great, thanks.
 
Just some fundamental problems in your sub...
trish said:
Private Sub cmdSearchLine_Click()

DoCmd.ShowAllRecords <This is telling your MAIN form to show all records
DoCmd.GoToControl ("Line") <Trying to go to "Line" control in MAIN form
DoCmd.FindRecord Me!SearchLine

Line.SetFocus
SearchLine = Line.Text
SearchLine.SetFocus
strSearch = SearchLine.Text
End Sub
The syntax to refer to controls in the subform is different...
MainForm.controls("subformName").form.controls("line").setfocus
(or something like that...search the forum for "refer to control in subform")
I think you will run into more problems in your sub, but this will get you started.
 

Users who are viewing this thread

Back
Top Bottom