Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Command Button in Database

Discussion in 'Information Technology' started by excel_hari@yahoo.com, Jul 28, 2006.

  1. excel_hari@yahoo.com

    excel_hari@yahoo.com
    Expand Collapse
    Guest

    Hi,

    Im doing some lookup kind of operation by exporting 2 excel files in to
    access and then after lookup, the results (from a query) are exported
    as excel fle. All this has been dne within VBA.

    I dont want my user to press alt + F11 and then run the selected
    module/macro. I want to know as to whether I can offer user a button in
    the data base itself whereby as soon as it opens the user can click on
    it and generate the output in excel. :-

    a) Presently I had to make a form in which I created a command button
    with underlying code calling up my Lookup module/macro. It works
    perfectly. But, I dont like this method as user would have to first
    cick on the form and then press the button. In excel one could keep the
    button on the worksheet. In Access how does it work. Cant we have a
    button in the white space when a new DB is opened or in the gray space
    where the objects are listed on the left hand pane. (The command button
    Toolbox is greyed out in these cases).

    b) Also, in situation like mine, is it more "appropriate" to create
    command button in a FORM or witin a REPORT (I see that I have command
    buttons available even within Report). I havent worked with databases
    in a formal environment.

    Regards,
    HP
    India
     
  2. Loading...

    Similar Threads Forum Date
    Commandments Blogs Jun 29, 2016
    General Meet Hari Singh Nalwa - The Sikh Commander Who Was The Most Feared Warrior In Afghanistan History of Sikhism Jun 23, 2016
    Opinion The rescue operations of Delhi’s Love commandos Breaking News Feb 2, 2013
    SPECIAL for Guru GOBIND SINGH JI's Gurpurab- The Greatest Commander-Unparralled. Sikh Sikhi Sikhism Jul 12, 2012
    Canada First Canadian Sikh Soldier Takes Command of BC Regiment Breaking News Sep 14, 2011

  3. strive4peace

    strive4peace
    Expand Collapse
    Guest

    Command buttons need to be on forms

    Usually, the main menu form is specified to open when you
    open the database ...

    Tools, Startup...

    In order to assign a general procedure to the OnClick
    property directly, it must be a FUNCTION...

    OnClick -->
    =MyFunctionName()


    Warm Regards,
    Crystal
    Microsoft Access MVP 2006

    *
    Have an awesome day ;)

    remote programming and training
    strive4peace2006 at yahoo.com

    *

    excel_hari@yahoo.com wrote:
    > Hi,
    >
    > Im doing some lookup kind of operation by exporting 2 excel files in to
    > access and then after lookup, the results (from a query) are exported
    > as excel fle. All this has been dne within VBA.
    >
    > I dont want my user to press alt + F11 and then run the selected
    > module/macro. I want to know as to whether I can offer user a button in
    > the data base itself whereby as soon as it opens the user can click on
    > it and generate the output in excel. :-
    >
    > a) Presently I had to make a form in which I created a command button
    > with underlying code calling up my Lookup module/macro. It works
    > perfectly. But, I dont like this method as user would have to first
    > cick on the form and then press the button. In excel one could keep the
    > button on the worksheet. In Access how does it work. Cant we have a
    > button in the white space when a new DB is opened or in the gray space
    > where the objects are listed on the left hand pane. (The command button
    > Toolbox is greyed out in these cases).
    >
    > b) Also, in situation like mine, is it more "appropriate" to create
    > command button in a FORM or witin a REPORT (I see that I have command
    > buttons available even within Report). I havent worked with databases
    > in a formal environment.
    >
    > Regards,
    > HP
    > India
    >
     
  4. excel_hari@yahoo.com

    excel_hari@yahoo.com
    Expand Collapse
    Guest

    Crystal,

    Thanks for your suggestions.

    I have added my form to Startup. Now, when I open the DB, then I dont
    have the form occupying the maximum possible window space. I have to
    click on the Square box in the right hand top corner to maximise the
    size of the form. How do I set it so that everytime I open the Database
    the user gets to see it in maximized form.

    Please guide me.

    Regards,
    HP
    India
     
  5. strive4peace

    strive4peace
    Expand Collapse
    Guest

    Hi HP,

    make a macro

    Name --> AutoExec
    Action --> Maximize

    This will automatically execute when the database is opened

    Warm Regards,
    Crystal
    Microsoft Access MVP 2006

    *
    Have an awesome day ;)

    remote programming and training
    strive4peace2006 at yahoo.com

    *

    excel_hari@yahoo.com wrote:
    > Crystal,
    >
    > Thanks for your suggestions.
    >
    > I have added my form to Startup. Now, when I open the DB, then I dont
    > have the form occupying the maximum possible window space. I have to
    > click on the Square box in the right hand top corner to maximise the
    > size of the form. How do I set it so that everytime I open the Database
    > the user gets to see it in maximized form.
    >
    > Please guide me.
    >
    > Regards,
    > HP
    > India
    >
     
  6. excel_hari@yahoo.com

    excel_hari@yahoo.com
    Expand Collapse
    Guest

    Crystal,

    I could get the following code and it works well. I want to know one
    thing. Why is it that default action for a Form is not in maximize
    position. Cant that be somehow controlled by setting the form
    properties somewhere?


    Function Autoexec()
    On Error GoTo Autoexec_Err

    DoCmd.Maximize


    Autoexec_Exit:
    Exit Function

    Autoexec_Err:
    MsgBox Error$
    Resume Autoexec_Exit

    End Function

    Regards,
    HP
    India
     
  7. excel_hari@yahoo.com

    excel_hari@yahoo.com
    Expand Collapse
    Guest

    Crystal,

    I have one follow up doubt.

    I was using the autoexec code above and then a thought came to my head.
    Once it gets maximized and after that if I immediately exit out of the
    DB, then am not asked as to whether I want to save the DB. S, this
    means either of 2 things:-

    a) In access the maximixing action is not considered as part of "DB
    structure", so thats why while exiting out access doesnt prompt for
    saving the maximized form.

    OR

    b) In access the maximixing action is considered as part of "DB
    structure" and probably these things are autosaved, so thats why while
    exiting out access doesnt prompt for saving the maximized form.

    To check my hypothesis, I opened my DB and then I did Alt + F11 and
    then commented out my Autoexec macro (for Form maximizing) and then
    saved and closed the VB editor and then exited out of the DB. Next time
    I opened the DB, the form was in maximized form!!!

    So it seems that probably point b) is correct. But if that were true,
    then when I didnt have any autoexec code and had saved the DB after
    maxming form and reopned DB then it never used to be in maximized form.

    I cant understand as to whats the explanation here?

    Regards,
    HP
    India
     
  8. strive4peace

    strive4peace
    Expand Collapse
    Guest

    Hi Harry,

    you can put the following in the form LOAD (or OPEN) event

    DoCmd.Maximize


    Warm Regards,
    Crystal
    Microsoft Access MVP 2006

    *
    Have an awesome day ;)

    remote programming and training
    strive4peace2006 at yahoo.com

    *

    excel_hari@yahoo.com wrote:
    > Crystal,
    >
    > I could get the following code and it works well. I want to know one
    > thing. Why is it that default action for a Form is not in maximize
    > position. Cant that be somehow controlled by setting the form
    > properties somewhere?
    >
    >
    > Function Autoexec()
    > On Error GoTo Autoexec_Err
    >
    > DoCmd.Maximize
    >
    >
    > Autoexec_Exit:
    > Exit Function
    >
    > Autoexec_Err:
    > MsgBox Error$
    > Resume Autoexec_Exit
    >
    > End Function
    >
    > Regards,
    > HP
    > India
    >
     
  9. strive4peace

    strive4peace
    Expand Collapse
    Guest

    Re: Command Button in Database -- defaults

    Hi Harry,

    maximizing os not part of the form definition

    think of it this way: defaults are often like settings on
    the dashboard of your car. If you like a particular radio
    station, you press button "1" -- another person might press
    button "2"... or you might scan for a different channel You
    like the temperatire cooler, so you might not turn the
    heater on -- another person may choose to have heat.

    The bottom line is this: WHERE you are going and how fast
    you get there is not affected (directly)....

    >>>"In access the maximixing action is considered as part

    of "DB structure" <<<

    not true




    Warm Regards,
    Crystal
    Microsoft Access MVP 2006

    *
    Have an awesome day ;)

    remote programming and training
    strive4peace2006 at yahoo.com

    *

    excel_hari@yahoo.com wrote:
    > Crystal,
    >
    > I have one follow up doubt.
    >
    > I was using the autoexec code above and then a thought came to my head.
    > Once it gets maximized and after that if I immediately exit out of the
    > DB, then am not asked as to whether I want to save the DB. S, this
    > means either of 2 things:-
    >
    > a) In access the maximixing action is not considered as part of "DB
    > structure", so thats why while exiting out access doesnt prompt for
    > saving the maximized form.
    >
    > OR
    >
    > b) In access the maximixing action is considered as part of "DB
    > structure" and probably these things are autosaved, so thats why while
    > exiting out access doesnt prompt for saving the maximized form.
    >
    > To check my hypothesis, I opened my DB and then I did Alt + F11 and
    > then commented out my Autoexec macro (for Form maximizing) and then
    > saved and closed the VB editor and then exited out of the DB. Next time
    > I opened the DB, the form was in maximized form!!!
    >
    > So it seems that probably point b) is correct. But if that were true,
    > then when I didnt have any autoexec code and had saved the DB after
    > maxming form and reopned DB then it never used to be in maximized form.
    >
    > I cant understand as to whats the explanation here?
    >
    > Regards,
    > HP
    > India
    >
     
  10. excel_hari@yahoo.com

    excel_hari@yahoo.com
    Expand Collapse
    Guest

    Crystal,

    Thanks a lot for your responses.

    Regards,
    HP
    India

    strive4peace wrote:
    > Hi Harry,
    >
    > you can put the following in the form LOAD (or OPEN) event
    >
    > DoCmd.Maximize
    >
    >
    > Warm Regards,
    > Crystal
    > Microsoft Access MVP 2006
    >
    > *
    > Have an awesome day ;)
    >
    > remote programming and training
    > strive4peace2006 at yahoo.com
    >
    > *
    >
    > excel_hari@yahoo.com wrote:
    > > Crystal,
    > >
    > > I could get the following code and it works well. I want to know one
    > > thing. Why is it that default action for a Form is not in maximize
    > > position. Cant that be somehow controlled by setting the form
    > > properties somewhere?
    > >
    > >
    > > Function Autoexec()
    > > On Error GoTo Autoexec_Err
    > >
    > > DoCmd.Maximize
    > >
    > >
    > > Autoexec_Exit:
    > > Exit Function
    > >
    > > Autoexec_Err:
    > > MsgBox Error$
    > > Resume Autoexec_Exit
    > >
    > > End Function
    > >
    > > Regards,
    > > HP
    > > India
    > >
     
  11. strive4peace

    strive4peace
    Expand Collapse
    Guest

    you're welcome ;) happy to help

    Warm Regards,
    Crystal
    Microsoft Access MVP 2006

    *
    Have an awesome day ;)

    remote programming and training
    strive4peace2006 at yahoo.com

    *

    excel_hari@yahoo.com wrote:
    > Crystal,
    >
    > Thanks a lot for your responses.
    >
    > Regards,
    > HP
    > India
    >
    > strive4peace wrote:
    >
    >>Hi Harry,
    >>
    >>you can put the following in the form LOAD (or OPEN) event
    >>
    >>DoCmd.Maximize
    >>
    >>
    >>Warm Regards,
    >>Crystal
    >>Microsoft Access MVP 2006
    >>
    >> *
    >> Have an awesome day ;)
    >>
    >> remote programming and training
    >> strive4peace2006 at yahoo.com
    >>
    >> *
    >>
    >>excel_hari@yahoo.com wrote:
    >>
    >>>Crystal,
    >>>
    >>>I could get the following code and it works well. I want to know one
    >>>thing. Why is it that default action for a Form is not in maximize
    >>>position. Cant that be somehow controlled by setting the form
    >>>properties somewhere?
    >>>
    >>>
    >>>Function Autoexec()
    >>>On Error GoTo Autoexec_Err
    >>>
    >>> DoCmd.Maximize
    >>>
    >>>
    >>>Autoexec_Exit:
    >>> Exit Function
    >>>
    >>>Autoexec_Err:
    >>> MsgBox Error$
    >>> Resume Autoexec_Exit
    >>>
    >>>End Function
    >>>
    >>>Regards,
    >>>HP
    >>>India
    >>>

    >
    >
     

Share This Page