How to Create a Lookup for Record in a Subform (Not in Datasheet View)

D

DOYLE60

I have a mainform and a subform. The subform is not in database view, but in
form view. This does come into play. The subform has a field on it that is
unique across records in the mainform. That is, this field (MaterialNumber)
can only be found in one record of the mainform.

I have a look up combo box which finds records in the main form (BrandID). I
also have a look up combo box in the subform that finds records in it,
filtering on the current record in the mainform.

This all works fine.

However, a user may know the unique data in the subform (MaterialNumber) but
may not know what record in the main form (BrandID) it is on. Therefore, it is
hard to find.

So I want a third look up box that will find a record on the subform. That is,
it should find the mainform record first and then go to the subform record.

If I make an unbound lookup for all the unique items (MaterialNumber), what
would be the code for it to go to set the form properly?

MaterialNumber is a text field.
Also, I would like to go to the record but have no filters operating.

Thanks.

I know how to use the wizard to go to the Mainform but not the subform. On
another form I have code from the wizard (but slightly changed by me to rid it
of the annoying filtering). Here is that code, which may be a good start
(remember it has different names because it is for another form:
________________________________

On Error GoTo Err_BackToForm_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim rsFind As Recordset

stDocName = "ENTRYFORM2"

stLinkCriteria = "[PO]=" & "'" & Me![PO] & "'"
DoCmd.OpenForm stDocName
Set rsFind = Forms(stDocName).RecordsetClone
rsFind.FindFirst stLinkCriteria
Forms(stDocName).Bookmark = rsFind.Bookmark

Exit_BackToForm_Click:
Exit Sub

Err_BackToForm_Click:
MsgBox Err.Description
Resume Exit_BackToForm_Click
_________________________________________

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top