Results 1 to 9 of 9
  1. #1
    Modify_inc is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    100

    Save CustomerID used in one Form to another Forms table

    I currently have a form for adding customers, and it works fine. I have added a command button to the customer form that when clicked, opens a new form (Devices) for adding a new device that I want to assign to that customer. Yet that is where my problem is, I cannot get the Devices form to save the previous customer record ID to the Devices table.

    How do I tell Access that the Devices form is still part of the Customers form or linked to it, and that when I save the new device entires, to add that customers ID to the Device table? Of course I could add a customer search on the Devices form, but that would be redundant as seeing the Devices form is loaded initially from the Customers form via the command button.

    I admit, I 'm still learning, but I would love to figure this out.

    Thanks
    Mike

  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,626
    Have you considered a form/subform arrangement? No code would be required.

    Opening a dependent record on an independent form requires code that passes the ID value to the form.

    Review this thread for one poster's experience https://www.accessforums.net/forms/h...tml#post210672
    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
    Modify_inc is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    100
    Quote Originally Posted by June7 View Post
    Have you considered a form/subform arrangement? No code would be required.

    Opening a dependent record on an independent form requires VBA code that passes the ID value to the form.

    Review this thread for one poster's experience https://www.accessforums.net/forms/h...tml#post210672
    Thanks for the advice!
    No I didn't. That might be the simplest route.
    Thanks for the link, I will check it out also.

    Mike

  4. #4
    Modify_inc is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    100
    Well no luck...Apparently Access doesn't allow you to use split forms in a subform.

    It never fails for me.

    Thanks for the suggestion.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    I've never used the Split form. Looked at, never fits my requirements.
    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.

  6. #6
    Modify_inc is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    100
    Can I do this:

    Create a command button on my customers form to view devices for current customer? I know how to create it to view all devices created, but how do I just tell it to only view current customer's devices?

    Thanks
    Mike

  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,626
    Certainly. Options:

    1. dynamic parameterized query as form RecordSource, criteria references ID field/control on Customer form

    2. code opens form filtered to ID value, I use only VBA but macro has equivalent
    DoCmd.OpenForm "Devices", , , "CustID=" Me.ID
    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
    Modify_inc is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    100
    Quote Originally Posted by June7 View Post
    Certainly. Options:

    1. dynamic parameterized query as form RecordSource, criteria references ID field/control on Customer form

    2. code opens form filtered to ID value, I use only VBA but macro has equivalent
    DoCmd.OpenForm "Devices", , , "CustID=" Me.ID
    I understand step two, but you lost me in step one.

    I understand a little bit about the query used in the RecordSource for the form and how to modify it, but I do not understand or know how to create one for the command button.

    I am assuming that is what you are saying that I need to do, correct?

    Also using the code you provided resulted in a Compile Error, Expected: end of statement

    Doesn't that usually mean a line terminator or similar is missing?

  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,626
    Sorry, missing & to concatenate the string and the variable.

    DoCmd.OpenForm "Devices", , , "CustID=" & Me.ID

    I never use option 1 anyway.
    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.

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

Similar Threads

  1. Replies: 4
    Last Post: 12-14-2012, 03:42 PM
  2. Replies: 1
    Last Post: 12-04-2012, 07:08 PM
  3. Replies: 11
    Last Post: 07-24-2012, 07:50 PM
  4. Replies: 2
    Last Post: 03-01-2012, 12:21 PM
  5. Replies: 9
    Last Post: 01-20-2011, 02:22 PM

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