Results 1 to 6 of 6
  1. #1
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281

    Populating a Table With Calculated Form Controls

    Just about done with this project....Thank the Lord!!



    Okay, I bound the controls of these forms (Main/Sub) to their respective tables; (Thanks all for that bit of wisdom) however, I have several controls which are auto-populated with DLookUps

    Naturally, when I enter data into the bound controls that data is entered into the tables automatically; but, of course the controls which derive their data via a DLookUp

    That data does not automatically get entered into the table

    Thus, my question is what is the best way to populate a table with both bound and unbound controls

    Would I use an INSERT Query for the controls not bound or is there a better way?

    Thank You very much...

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    why do you want to store what is effectively a calculated or looked up value? just use the dlookup on your form, although there are often faster ways depending on the required output such as including the values in a query. But to answer your question, you would use an update query.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Could simply use code behind form that populates field:

    Me!fieldname = Me.controlName

    The trick is figuring out what event to put code in.

    But why save duplicate data? Why do you even need DLookup?
    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.

  4. #4
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281
    Ajax - June - As always - Thank you!

    Your questions illuminate the obvious gap between what I know and how much I don't know (but trying like hell to learn)

    I believe this bit of info might answer your questions about using calculated values - The owner of this project wants to use a flat table.

    So, I'm using LookUps in the controlsource of as many controls as I can to speed up data entry, but once those LookUps autopopulate their respective controls I then need to add the values of those controls to what will be the main/flat table

    And, of course this is just the main form of a main/sub form combination and the subform is completely bound...UGH!!!

    Anyway,

    Currently I'm looking at unbinding all of the controls and adding their values with VBA using code similar to below - This seems woefully inefficient -
    Code:
    Private Sub Command36_Click()
    Dim Db As DAO.Database
    '
    Dim Rs As Recordset
    '
    Set Db = CurrentDb
    Set Rs = Db.OpenRecordset("Select * From TblData")
    '
    Rs.AddNew
      Rs("Recipient") = Me.txtRecipient
        Rs("ReipientFaxNum") = Me.TxtFaxNum
          Rs("RequestDt") = Me.TxtRqstDate
            Rs("RequestPriority") = Me.TxtRqstPriority
    
    'There are 43 fields in this table so this goes on for a bit - figured you get the gist with just this snippet of code.
    
    Rs.Update
    End Sub
    Ajax - I'm not sure what you mean by, "just use the dlookup on your form..." I have placed these dlookups in the control source of the control - are you referring to something else?
    Also, The desired output is to send a report directly to the printer

    Thanks again you two for helping me out

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    No, access isn’t really intended for flat file data input so suspect you will struggle to create an effective app. Fine of course to use flat file output for reports and exports

    Good luck with your project

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I think Ajax was saying to do the DLookup calc whenever the value is needed, not to save it.

    Why does the user dictate data structure? Why should they care? As long as they can enter data and get desired output why should they even know what the data structure is?

    Whether you use INSERT/UPDATE actions or recordset or my example, the real trick is still figuring out what event to put code into. You are using a button Click event which may be adequate. What if user clicks button again on the same data? Will a duplicate record be created?
    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: 06-08-2016, 05:38 PM
  2. Populating form controls with old data
    By FormerJarHead in forum Access
    Replies: 2
    Last Post: 01-12-2013, 06:25 AM
  3. Replies: 1
    Last Post: 01-09-2013, 02:42 PM
  4. Auto populating Form controls
    By eww in forum Forms
    Replies: 1
    Last Post: 08-09-2010, 12:49 PM
  5. Calculated Text Box Populating in Table
    By Debbie in forum Access
    Replies: 2
    Last Post: 11-13-2006, 08:02 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