Link to home
Start Free TrialLog in
Avatar of camco
camco

asked on

Look Up in Form

I have a form that has two sub forms. The subforms use the same table for the record source. I would like a field that you could enter text and have it find a record in one of the two subforms based on the text that you enter in the look-up field.

Thanks for the help!
Ward
Avatar of nico5038
nico5038
Flag of Netherlands image

Just create a lookup textfield and add a "Lookup" button per subform.

The button can issue a filter command like:

me.sfrmSubform1.Form.Filter = "FieldA like '*" & me.txtFilter1 & "*'"
me.sfrmSubform1.Form.FilterOn = True

Same goes for the second button.
This will search the FieldA matching your txtFilter1 value even for a part.

Is that what you need?

Nic;o)
Avatar of camco
camco

ASKER

Is the txtFilter1 in "me.txtFilter1" the name of my unbound text box that I enter the search criteria in?

ward
Correct Ward.
I anticipated on possibly two separate fields, one per subform...

Nic;o)
Avatar of camco

ASKER

Hi Nic,

This is waht I have but when I click on the button I get  an error meassage compile error. method or data member not found. It highlights .txt34 in yellow.

Private Sub Command37_Click()

Me.Subform1.Form.Filter = "OrderNumber like '*" & Me.txt34 & "*'"
Me.Subform1.Form.FilterOn = True

   
End Sub

Thanks Again!
Ward
Goto the field txt34 on your form in editmode and right-click it to select the properties.
There goto the "Other" tab and check or the name is effectively "txt34".
Also check this for the OrderNumber on the subform1.

Nic;o)
Avatar of camco

ASKER

They have the same name. I am stumped
ASKER CERTIFIED SOLUTION
Avatar of nico5038
nico5038
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of camco

ASKER

Thanks a million!!!
Ward
You're welcome ;-)
Just try to be very secure on the names you use and prefixing/renaming fields and other objects will really pay-off !

Nic;o)