Results 1 to 7 of 7
  1. #1
    clairebear is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    3

    Auto-fill a Subform using a Data from the mainform


    Click image for larger version. 

Name:	msaccess.JPG 
Views:	13 
Size:	49.6 KB 
ID:	21648
    Hi,
    So I am new in Access and what Im trying to do is to allow my subform to auto-fill data from my main form.
    MY main form is frmBilling and subform is frmDetails. Fields in my main form includes Billing No which is an Autonumber field. Subform also includes a Billing No field.
    What I would like to do is that whenever Access creates a new Billing No, it would fill the subform with the corresponding Billing No.

    Hope you could help me.
    Thanks in advance.

  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,771
    Is BillingNo set as primary key field in Billing table? Set subform container control Master/Child Links properties. This will synchronize records. The BillingNo will automatically populate into the subform records when data is entered into any other subform field.

    Might want to make the two BillingNo field names slightly different, such as BillingNoPK and BillingNoFK.

    Advise no spaces or special characters/punctuation (underscore is exception) in naming convention.
    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
    clairebear is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    3
    Yes, the billingno is set as primary key in the billing table.
    However, another problem is that the data in the subform is pre-entered. which means that when BillingNo in the main form is created, i want that it will automatically show in the subform and update the data in the table. Is this possible?

    Thanks

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Suggest you look for youtube videos for Msaccess --form/subform like this one

  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,771
    I don't understand. If the data in the subform is pre-entered, when does that happen? If there is not already a value in the subform BillingNo, the main and subform records cannot synchronize. Your image makes no sense.
    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
    clairebear is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    3
    Quote Originally Posted by June7 View Post
    I don't understand. If the data in the subform is pre-entered, when does that happen? If there is not already a value in the subform BillingNo, the main and subform records cannot synchronize. Your image makes no sense.
    Okay, here's more details about the form Im trying to make. The form is supposed to create a Unique billing number and associate it to the DRDetails. The DR Details data are pulled up by Access thru the Client Name. Thus, DR Details are stored first. Then when the user opens the form and types in the clients name in the mainform, the corresponding data will be shown in the subform and a corresponding number will be generated in the Billing No field in the main form. What I want to happen is the when the corresponding number in the Billing form is generated, I also want it to appear in the subform and when I click the Save number i would want to save it in the table.

    For example I typed in Client A. All DRDEtails with Client A's name will appear. Then Access generated billing no 10. I want all Clients A's DRDetails to also have billing no. 10. Do I make sense? Thanks.

  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,771
    Conventional approach would be to create the billing record then select the client records to be associated with the billing.

    In your situation, use an UPDATE sql action. The real trick is figuring out what event to put the code into.

    CurrentDb.Execute "UPDATE tablename SET BillingNo=" & Me.BillingNo & " WHERE ClientID=" & Me.Client & " BillingNo Is Null"

    Why is the Amount value showing aligned left like text?
    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: 1
    Last Post: 03-22-2015, 02:21 PM
  2. Replies: 2
    Last Post: 12-18-2012, 11:41 AM
  3. Replies: 1
    Last Post: 12-21-2011, 02:11 PM
  4. Replies: 6
    Last Post: 04-14-2010, 11:03 AM
  5. copying data from subform to mainform
    By wasim_sono in forum Forms
    Replies: 0
    Last Post: 03-10-2006, 04:35 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