Results 1 to 10 of 10
  1. #1
    peterjb44 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    6

    Question transfer company name from one form to another form

    Hi All,

    been trying to figure this out..

    i would like Company name from current open CustomerF form Company field to go in EquipmentF form CompanyID field once i press add equipment button on CustomerF form.....i would also like it to be a new record

    i have done this so far...but is not working the way i would like

    Code:
    private sub addequipmentbutton_click()
    docmd.openform "EquipmentF",,,"company = '" & company & "'",,acDialog
    end sub


    what i have noticed

    if the company has equipment added to my equipment table then when i click add equipment button on the current CustomerF form the equipment form has the correct company name, but it show the first record.

    if its a new customer i am adding details for or a company with no equipment and i go to enter their equipment, then click add equipment button then the EquipmentF form opens as a new blank record with no company name

    is there a way to sort this the way i would like it to work?




    thanks

    peter

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Should not save company name, just company ID.

    Why not use a form/subform arrangement?

    What is the database structure (tables and relationships)?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    peterjb44 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    6
    HI June7,


    thanks for your reply

    both Company name (CustomerT table) and CompanyID (EquipmentT table) should be saved

    not sure what you mean with form/subform arrangment......pretty much new to this

    the two tables are CustomerT and EquipmentT
    Company is a field in CustomerT which is related to CompanyID (field) of EquipmentT 1 to many

    thanks

    peter

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    peterjb44 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    6
    yes i have a form like that with company name and address etc at the top and a list of their equipment below, but on my CustomerF form this has much more details on it, just thought it would be nice to be able to add equipment directly from the CustomerF form after that was filled in

    can this be done

  6. #6
    peterjb44 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    6
    sorry my OP code should of been

    Code:
    docmd.openform "EquipmentF",,,"companyid = '" & company & "'",,acDialog

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    If you are adding a new customer and their associated equipment, a form/subform is the easiest approach. Otherwise, will require VBA code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    peterjb44 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    6
    ok, i have no idea how to do that, any ideas?

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    How to do what - VBA? The code will involve:

    1. Saving the new customer record.
    DoCmd.RunCommand acCmdSaveRecord

    2. Opening the equipment form and passing the new customer ID
    DoCmd.OpenForm "Equipment", , , ,acFormAdd, , Me.CustomerID

    3. Populating the Equipment form foreign key customer ID field with the passed value
    Sub Form_Current()
    If IsNull(Me.CompanyID) Then
    Me.CompanyID = Me.OpenArgs
    End If
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    peterjb44 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    6
    Thanks June7

    i had to change the end bit of no2 from customerid to company as i was getting a number

    Thanks again your great

    peter

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 04-01-2013, 01:43 PM
  2. Replies: 1
    Last Post: 10-31-2012, 01:27 PM
  3. Replies: 4
    Last Post: 10-20-2010, 10:38 AM
  4. form data transfer to a report
    By poppinggizmo in forum Forms
    Replies: 1
    Last Post: 06-06-2010, 09:00 PM
  5. Transfer Text to Unbound Form
    By DWS in forum Forms
    Replies: 3
    Last Post: 08-25-2009, 08:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums