Open Pop-Up Forms Based On Criteria in Main Forms

BlueFraggle

Registered User.
Local time
Today, 09:38
Joined
Jul 25, 2007
Messages
10
Hi All,

I am hoping you guys may be able to help me.

I have a Main Form that contains Record Details (Product Code being the primary key), a Yes/No toggle field and a Command Button (among others).

I then have 2 Pop-Up Forms (Form1 and Form2) that I wish to open based on criteria set in the Main Form.

When I click on the Command Button, I wish to open Form1 IF the Yes/No toggle field is set to Yes, or open Form2 IF it is set to No.

A further complication is that when Form1 or Form2 opens I need it to display the details relevant to the current record showing on the Main Form (Product Code is also contained in the Pop Up forms)

Is there a way I can do this?

Many thanks in advance for your help.

Cheers

BlueFraggle
 
Do this in the code for the button:
Code:
If Me.YourYesNoToggleNameHere = True Then
   DoCmd.OpenForm "Form1NameHere", acViewNormal,, "[Product Code]=" Me![Product Code]
Else
   DoCmd.OpenForm "Form2NameHere", acViewNormal,, "[Product Code]=" Me![Product Code]
End If
 
Thank you so much ........ I will give this a try in the morning.

Cheers
 
Oh, one thing too - the code I gave should be fine if Product Code is a number, but if it is text, you'll need to add single quotes around it like this:

Code:
If Me.YourYesNoToggleNameHere = True Then
   DoCmd.OpenForm "Form1NameHere", acViewNormal,, "[Product Code]=[color=red][b]'[/b][/color]" Me![Product Code] & [color=red]"'"[/color]
Else
   DoCmd.OpenForm "Form2NameHere", acViewNormal,, "[Product Code]=[color=red][b]'[/b][/color]" Me![Product Code] & [color=red]"'"[/color]
End If
 
Last edited:

Users who are viewing this thread

Back
Top Bottom