Senin, 11 Juli 2011

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

 

Hi Bill, Thank you for the reply.

I just read the instructions and code you gave me. I used them but when I try to use the combo box on Form view it tells me it didn't find an argument with name, and highlighted in yellow the first line of the code.

> > Private Sub cboState_BeforeUpdate(Cancel As Integer)

I tried a part of the code in an extra Command Button (btnGO being the Command Button) to click on, after choosing the respective Type (from the Option Frame) and State from the Combo Box, but it shows me the same error on the line

Private Sub btnGO_Click()

Maybe it has something to do with what you commented me afterwards. I'm not sure how to solve this. I don't think it's a problem about the name of the command button or Combo Box, I put the complete names when I pasted your code on Access.

Thank you again!

--- In MS_Access_Professionals@yahoogroups.com, "Bill Mosca" <wrmosca@...> wrote:
>
> I forgot to mention you will need to put your database in a trusted location so the code can run. Let us know if you need help with that.
>
> Bill
>
> --- In MS_Access_Professionals@yahoogroups.com, "Bill Mosca" <wrmosca@> wrote:
> >
> > Hi Cesar
> >
> > Welcome to our group. And I'm sorry your post went unanswered for so long.
> >
> > You can use the combo's AfterUpdate event to open the form based on the selection in your option frame. Here I named the option frame "fraType".
> >
> > Private Sub cboState_BeforeUpdate(Cancel As Integer)
> > Select Case fraType
> > Case 1
> > DoCmd.OpenForm FormName:="F1", _
> > WherCondition:="State = '" & cboState & "'"
> > Case 2
> > DoCmd.OpenForm FormName:="F2", _
> > WherCondition:="State = '" & cboState & "'"
> > Case Else: MsgBox "Please select a Type. " _
> > & "Then open the dropdown and reselect the state."
> > End Select
> >
> > End Sub
> >
> > To get this code in place, open the main menu form in design view. Click on the combo so it is selected. in the properties sheet, click on the Events tab and find the On After Update line.
> >
> > Click on that line and you should see a builder button (...) to the right of the line. Click it and select Event Procedure. That will open the code window to that event.
> >
> > Paste my code in there, changing the names of anything I got wrong.
> >
> > Now when you have an option selected the combo will know which form to open and which state to bring up.
> >
> > Regards,
> > Bill Mosca, Founder - MS_Access_Professionals
> > http://www.thatlldoit.com
> > Microsoft Office Access MVP
> > https://mvp.support.microsoft.com/profile/Bill.Mosca
> >
> >
> >
> > --- In MS_Access_Professionals@yahoogroups.com, cesarmzp89 <no_reply@> wrote:
> > >
> > > 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
> > >
> >
>

__._,_.___
Recent Activity:
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar