Senin, 11 Juli 2011

Re: [MS_AccessPros] Use both buttons and combo box to open a Forms.

 


Thank you for the help! I actually didn't have a command button, but it is a better idea. I tried your code and it works very good!

I changed it a little to add a message in case no option was selected, and now it's running perfectly as I wanted.

Have a great day!

--- In MS_Access_Professionals@yahoogroups.com, "John Viescas" <john@...> wrote:
>
> Cesar-
>
> Do you have a command button to cause the form you want to open? If so, you can
> test the value of the buttons to see which form to open in code. I assume the
> "buttons" are in an Option Group, so you only need to test the value of the
> group control.
>
> Private Sub cmdOpenForm_Click()
> If Me.optType = 1 Then
> ' Open form A
> DoCmd.OpenForm "FormA", WhereCondition:="State = '" & Me.cmbState & "'"
> Else
> ' Open form B
> DoCmd.OpenForm "FormB", WhereCondition:="State = '" & Me.cmbState & "'"
> End If
> End Sub
>
>
> John Viescas, author
> Microsoft Office Access 2010 Inside Out
> Microsoft Office Access 2007 Inside Out
> Building Microsoft Access Applications
> Microsoft Office Access 2003 Inside Out
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
>
>
>
> -----Original Message-----
> From: MS_Access_Professionals@yahoogroups.com
> [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of cesarmzp89
> Sent: Friday, July 08, 2011 7:26 PM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: [MS_AccessPros] Use both buttons and combo box to open a Forms.
>
> Hello there!
>
> I'm using Access 2007, and I have the following forms:
>
> F1 - A form that has an analysis for TYPE A institutions for each State.
> F2 - A form that has an analysis for TYPE B institutions for each State in the
> Country.
> Main Menu - A form that is by default the form that opens up when I open this
> database.
>
> Let's say States are STATE1, STATE2, and so on.
>
> So my objective is the following:
>
> In the Main Menu, I have 2 buttons that alternate (you can only choose 1 option
> of those 2, the options being TYPE A and TYPE B) and a Combo Box (That displays
> the name of the States: STATE1, STATE2, ..., STATEn).
>
> So I want that, when you choose, for example, TYPE A and then choosing from the
> Combo Box a State -say, STATE1, for example- it opens F1 in the STATE1 Record.
> If I choose TYPE B, and STATE10 afterwards, it opens F2 in the STATE10 Record.
>
> I have a combo box that opens F1 in the State I choose... but I don't know how
> to tell it to open F2 or F1 depending on the Value of the buttons that
> alternate. Is that possible? Or is there any way of doing this another way?
>
> I appreciate the help.
> Thank you for your time and have a great day!
>
> Cesar
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar