Open a form depending on conditions

Chunk

Registered User.
Local time
Today, 08:06
Joined
Oct 25, 2004
Messages
64
I have a search form, that can be opened by both my "product_enquiry" and my "edit_product" form.

When you select a value on the product search form, i want it to open another form at a specific record.

Easy you might think, but what If i want it to work out which form to open.

So if: A button on Edit product was clicked on to open product search, the value found in product search should be loaded into edit product.

But if it was a button on product enquiry, the record should be opened on the product enquiry form.

Can anyone help?
 
I'm not sure I understand what you're trying to do, but if you wish to open more than 1 form with same record showing. Paste the code below onclick command button.


On Error GoTo Err_Handler

Dim strFieldName As String
Dim strForm As String

strForm = "FormYouWishToOpen"
strFieldName= "[FieldName]='" & Me.FieldName& "'"

DoCmd.OpenForm strForm, , , strFieldName

Exit_Here:
Exit Sub

Err_Handler:
MsgBox Err.Description & " " & Err.Number
Resume Exit_Here
End Sub


hth,
Michael
 
I need to pass a value to a form, so that it knows what form opened it. Then I need the form to reopen the form that opened it.

For example.

Product Enquiry
Product Edit

Are both forms with buttons that open "Search form".

Search form has a button, which opens a form, at a specified record.

I need to control the form that search form opens.

If product enquiry opened search form, then search forms button must open product enquiry at the specified record.

If product edit opened search form, then search forms button must open product editat the specified record.

I hope that is clear. :)
 
Use the openargs argument of the DoCmd.OpenForm method to pass to the form that's being opened the form name that's doing the opening.

From either the edit_product or product_enquiry forms, this goes in the on click events for the command buttons that open the search form.

DoCmd.OpenForm "MySearchForm", , , , , , Me.Name

Now the search form knows which form called it by its openargs argument:

If Len(Me.OpenArgs) > 0 Then
...
DoCmd.OpenForm Me.OpenArgs
...
End If

Without more information, its hard to guess how to synchronize the form (re?)opened by the search form (Ukraine82s method looks promising...)

hth,
 

Users who are viewing this thread

Back
Top Bottom