Welcome to SPN

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

Sign Up Now!

Help with Macro (Copying contents in a field)

Discussion in 'Information Technology' started by Adam Charlton, Jul 28, 2006.

  1. Adam Charlton

    Adam Charlton
    Expand Collapse
    Guest

    I need to make a macro that copies the field value on the active page of a
    form when I click a button. Here is what I need it to do:

    Click button on a form, Run Macro:

    Macro Copies field in form called PoLineItemID

    Macro goes to a subform and checks if a line item is has a checked checked
    box in a field, if so copies the value from the main form into another
    field.

    I really don't know much about macros, Im experimenting but its a little bit
    hard to figure out.

    Thanks if you can help.

    Adam
     
  2. Loading...


  3. Steve Schapel

    Steve Schapel
    Expand Collapse
    Guest

    Adam,

    Whereas you can achieve your purpose with a macro, I think it would help
    you to think of your purpose in a different way (if you don't mind me
    saying so!) For a start, it is helpful to remember that forms do not
    have data (or fields). Fields and data are ultimately in tables, or
    defined in queries based on table data. Forms can be a handy way to
    access the data in the tables. But when it comes to manipulating and
    working with the data, it is normally best to think of going back to the
    tables/queries.

    So, when you ask the macro to "checks if a line item has a checked
    checked box in a field" in your subform, you are really looking at the
    data in the table/query that the subform is based on. One way of doing
    this is to use a DCount function, and if you were using a macro, this
    would probably be used in the Condition column of the macro design,
    something the equivalent of this...
    DCount("*","YourSubformQuery","[YourYesNoField]=-1")>0
    So you are not actually looking at the subform as such.

    And when you say "copies the value from the main form into another
    field", well no, this is not normally the way to do things in a databse.
    Most likely you will be using an Append Query or an Update Query to
    change or add data to the table(s) in question. If you were doing this
    in a macro, you would use the OpenQuery action to run the append or update.

    Without knowing more specific details, it is hard to give more precise
    advice, but hopefully this will help point you in the right direction.

    --
    Steve Schapel, Microsoft Access MVP

    Adam Charlton wrote:
    > I need to make a macro that copies the field value on the active page of a
    > form when I click a button. Here is what I need it to do:
    >
    > Click button on a form, Run Macro:
    >
    > Macro Copies field in form called PoLineItemID
    >
    > Macro goes to a subform and checks if a line item is has a checked checked
    > box in a field, if so copies the value from the main form into another
    > field.
    >
    > I really don't know much about macros, Im experimenting but its a little bit
    > hard to figure out.
    >
    > Thanks if you can help.
    >
    > Adam
    >
    >
     
  4. Adam

    Adam
    Expand Collapse
    Guest

    Thanks Steve! You gave me a lot to think about. I think I can try to work
    on that and see where it takes me. I have found with Access it has been
    like learning a new language. Once I completely understand the concept of
    what is needed, it all starts to come together. It just takes time to learn
    the right terms, and figure out the actions and proceedures to accomplish
    what I want. You have indeed pointed me in the right direction. I really
    appreciate it.

    "Steve Schapel" <schapel@mvps.org.ns> wrote in message
    news:%232QazWhoGHA.4040@TK2MSFTNGP05.phx.gbl...
    > Adam,
    >
    > Whereas you can achieve your purpose with a macro, I think it would help
    > you to think of your purpose in a different way (if you don't mind me
    > saying so!) For a start, it is helpful to remember that forms do not have
    > data (or fields). Fields and data are ultimately in tables, or defined in
    > queries based on table data. Forms can be a handy way to access the data
    > in the tables. But when it comes to manipulating and working with the
    > data, it is normally best to think of going back to the tables/queries.
    >
    > So, when you ask the macro to "checks if a line item has a checked checked
    > box in a field" in your subform, you are really looking at the data in the
    > table/query that the subform is based on. One way of doing this is to use
    > a DCount function, and if you were using a macro, this would probably be
    > used in the Condition column of the macro design, something the equivalent
    > of this...
    > DCount("*","YourSubformQuery","[YourYesNoField]=-1")>0
    > So you are not actually looking at the subform as such.
    >
    > And when you say "copies the value from the main form into another field",
    > well no, this is not normally the way to do things in a databse. Most
    > likely you will be using an Append Query or an Update Query to change or
    > add data to the table(s) in question. If you were doing this in a macro,
    > you would use the OpenQuery action to run the append or update.
    >
    > Without knowing more specific details, it is hard to give more precise
    > advice, but hopefully this will help point you in the right direction.
    >
    > --
    > Steve Schapel, Microsoft Access MVP
    >
    > Adam Charlton wrote:
    >> I need to make a macro that copies the field value on the active page of
    >> a form when I click a button. Here is what I need it to do:
    >>
    >> Click button on a form, Run Macro:
    >>
    >> Macro Copies field in form called PoLineItemID
    >>
    >> Macro goes to a subform and checks if a line item is has a checked
    >> checked box in a field, if so copies the value from the main form into
    >> another field.
    >>
    >> I really don't know much about macros, Im experimenting but its a little
    >> bit hard to figure out.
    >>
    >> Thanks if you can help.
    >>
    >> Adam
     

Share This Page