Select record in one form and open it in another.

J

Jakeao

I have a main form where people can search for electrical parts on. I'm
trying to set it up so they can look for parts by category ie. fuses,
breakers, etc... I got it to work so they can type in a keyword and it
opens the category up in a popup form where they can then scroll through the
records.

I'm now trying to get it so when they click on a record and click the
'select' button the record in the popup form opens up the detailed
informaiton in the main form, and closes the popup form. Any Ideas? Thanks
for the help.
 
P

Piet Linden

I have a main form where people can search for electrical parts on. I'm
trying to set it up so they can look for parts by category ie. fuses,
breakers, etc...   I got it to work so they can type in a keyword and it
opens the category up in a popup form where they can then scroll through the
records.

I'm now trying to get it so when they click on a record and click the
'select' button the record in the popup form opens up the detailed
informaiton in the main form, and closes the popup form. Any Ideas? Thanks
for the help.

pass the filter to the second form in the Open event...

Check out the OpenForm command... one of the arguments is a filter
which you can use to filter which records you will see when the form
opens.
 
G

Graham Mandeno

Hi Jakeo

I'll assume your parts table has a primary key, and that the PK value of the
selected record is available in the lookup form (either from a listbox or a
continuous form where the part is selected). All you need to do is provide
a WhereCondition argument when you open the details form:

DoCmd.OpenForm "Name of details form", _
WhereCondition:="[name of PK field]=" & SelectedValue

where SelectedValue is the part number of the selected part.

If your PK is a text field then you must enclose the value in quotes:

DoCmd.OpenForm "Name of details form", _
WhereCondition:="[name of PK field]='" & SelectedValue & "'"
 
J

Jakeao

Here is the code I have to open the cotinuous form to select from.

Private Sub Keywordsearch_Click()
'this opens the "mpl" form based on the choice in the "keywordsearhc field"'
If IsNull(keywordsearchbox) = False Then
DoCmd.OpenForm "mpl", , , "[keyword]='" & Me.keywordsearchbox &
"'"

'I need to figure out the error message stuff'

If Me.Recordset.NoMatch Then
Me!searchbox = Null

If Me.Recordset.NoMatch Then
MsgBox "Error.", vbOKOnly + vbInformation, "Error."

End If
End If
End If

End Sub


The real problem I'm having is getting the selected information in the popup
form to go bak to the main form. I have the code to close the popup form
figured out, I just need to know how to transfer the selected record
information from the popup form back to the main form.


Private Sub mplselect_Click()

DoCmd.Close acForm, "mpl", acSaveNo

End Sub
 

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