Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Feb 2009
    Location
    Kings Park, Victoria, Australia
    Posts
    90
    Thanks
    15
    Thanked 5 Times in 5 Posts
    My database has the following fields, which are accessed by various forms.

    PostalAddress1
    PostalAddress2
    PostalSuburb
    PostalState
    PostalPostcode
    BusinessAddress1
    BusinessAddress2
    BusinessSuburb
    BusinessState
    BusinessPostcode

    What I would like to do is have the values of the Postal fields become the default for the Business fields to save typing when both addresses are the same. Is this possible? If so, How?

    Regards,
    Maria
    Maria
    Simmo7
    Victoria, Australia

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    You can't quite do this default values, because default values are present before you do any data entry.

    There are three options I can think of.

    • Use the After Update event of each of Postal Address fields, to set the value of the corresponding Business address field. Perhaps only if it is null, so you don't lose anything different you have already typed it.
    • Have a command button that copies all the Postal Address fields into the Business Address fields in one go.
    • Have another Yes/No field "Use Postal Address" . Then any queries that want a Business Address check the value of this Yes/No field. If it is Yes, the query just returns the Postal Address as the Business Address.
    Regards
    John



  3. #3
    Star Lounger
    Join Date
    Feb 2009
    Location
    Kings Park, Victoria, Australia
    Posts
    90
    Thanks
    15
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by John Hutchison View Post
    You can't quite do this default values, because default values are present before you do any data entry.

    There are three options I can think of.

    • Use the After Update event of each of Postal Address fields, to set the value of the corresponding Business address field. Perhaps only if it is null, so you don't lose anything different you have already typed it.
    • Have a command button that copies all the Postal Address fields into the Business Address fields in one go.
    • Have another Yes/No field "Use Postal Address" . Then any queries that want a Business Address check the value of this Yes/No field. If it is Yes, the query just returns the Postal Address as the Business Address.
    I would like to use the After Update event on the Postal Addresses to set the Business Address Fields, but I am not sure of how to code this correctly so that existing text is not overwritten.

    Using this method, would mean only minor changes to the existing database.
    Maria
    Simmo7
    Victoria, Australia

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Here is one example, for PostalAddress1.
    There are a few situations to consider.

    The simplest option would be to only do this in new records. This simplifies initial data entry, but leaves updates to be done manually.
    Otherwise you need to think about...
    If BusinessAddress1 is currently the same as PostalAddress1, then presumably you want it to update to the new value?
    If you delete PostalAddress1, then do you want BusinessAddress1 deleted, if it is the same as what you have just deleted from Postaladdress1?


    Code:
    If me.NewRecord then
     me.BusinessAddress1 = me.PostalAddress1
    end if
    Regards
    John



  5. #5
    Star Lounger
    Join Date
    Feb 2009
    Location
    Kings Park, Victoria, Australia
    Posts
    90
    Thanks
    15
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by John Hutchison View Post
    Here is one example, for PostalAddress1.
    There are a few situations to consider.

    The simplest option would be to only do this in new records. This simplifies initial data entry, but leaves updates to be done manually.
    Otherwise you need to think about...
    If BusinessAddress1 is currently the same as PostalAddress1, then presumably you want it to update to the new value?
    If you delete PostalAddress1, then do you want BusinessAddress1 deleted, if it is the same as what you have just deleted from Postaladdress1?


    Code:
    If me.NewRecord then
     me.BusinessAddress1 = me.PostalAddress1
    end if
    Thanks John,

    That is exactly what I wanted - I have now added this to each of the Postal Address fields on the Data Entry Forms for new records. This will save having to type the same text twice when both addresses are the same. For existing records nothing should be changed automatically - all updates on existing records are done manually as needed.

    Regards,
    Maria
    Maria
    Simmo7
    Victoria, Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •