Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2008
    Posts
    25

    Question Unanswered: Simply, copy and paste question!?

    Hi Everyone.

    I have a form with a field, "existing Address", and within the main form, I have a subform, which looks up using a reference, an address, but this is in 4 different fields, ie., address 1, address 2 etc.

    What I need to do is:

    When a user chooses existing from a field called NeworExisting, it autopopulates the field, existing address with the data from the subform, fields, address 1, address 2 etc.

    Can any one help?

    It seems to be a straight forward copy and past question, but as a novice, I am struggling!

    Thanks in advance for all your help.

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    You need to look at things like

    ExistingAddress = Add1 & vbcrlf & Add2 & vbcrlf & Add3 & vbcrlf & Add4
    Mind you, that syntax is wrong, but I gotta go right now... hopefully it will put you on the right track.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Jan 2008
    Posts
    25
    This doesn't appear to be working for me

    Can anyone suggest anything else?

  4. #4
    Join Date
    Feb 2002
    Posts
    108
    I dont think you should use copy/paste. I think StarTrekker is right.

    Try:

    FieldtoPopulate=dlookup("LookedUpData","TabletoLoo kin","[KeyField]='" & me!Address1 & ", " & Address2 & ", " & Address3 & "')

    Now make sure you enter the ' after the = sign and before the closing )
    Also the format of Address1 & ", " & Address2 & ", " & Address3 & "')
    depends on how all the address info is stored in the other table you are looking it up from, for example:

    If stored as: 123 Main St, Columbia, SC 29203
    If the comma is not stored in the Address1 field you must type code as I stated above, but if you just store as: 123 Main St Columbia SC 29203
    Then don't type the comma but you will still have to use the " " (space)

    Hope this helps. If not post some of the code so we can "see" what you have and how you are trying it now.

  5. #5
    Join Date
    Feb 2002
    Posts
    108
    Sorry, hit enter to quick.

    I was also going to say if you still think copy/paste is better/easier option:

    Try Microsoft Access tips: Clipboard Functions (32-bit)

    This is Allen Browne's answer to copy/paste and it works great.

  6. #6
    Join Date
    Jan 2008
    Posts
    25
    thanks for the reply jkevin.

    I have tried your code - and this is my "version" of your code, but I cannot get it to work - as a complete novice - I am sure it is something simple!

    I have this in the field where I wish to populate the data as an "on enter" event.

    On my form, I have the Contract No field entered by the user, and this then will populate the subform "regional download subform".

    The table with the customer details is call Regional Download and the field used as a key field is the Contract No field.

    Can you offer any further advice?


    ---

    Private Sub New_Saleslead_NameAddress_Enter()
    FieldtoPopulate = DLookup("contract_no", "regional_download", "[contractno]='" & Me!Site_Address_Line_1 & ", " & Site_Address_Line_2 & "")

    End Sub
    ---

  7. #7
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    I think you need to change that contract number expression. What that code does is gets a contract_no from a table called regional_download where that table's contractno (spelled differently than the fetched contract_no) is the same as the form's site_address_line_1 and a comma and the form's site_address_line_2 and gets the fetched contractno and sticks it in a field called FieldtoPopulate.

    That doesn't seem to logical to me; have a go at getting it closer to what you need?

    I also think jkevin has kinda sent you astray a touch by using the term "key field" which I think he meant "the relevant field".

    What really makes this hard is not being able to see your structure or know what is on your form.

    The solution will be simple once it's all known.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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