Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    For a start, should not have two ADM tables. One table with an Over_Under field. Should not have employee names in this table, only EmployeeID.



    Next, convert all those embedded macros to VBA.

    Should do C&R regularly, especially during development.

    You want data entered on a subform to update the data on a subsubform that is on a different subform? This gets stranger and stranger!

    I don't see any code that is even attempting to do that. It would be rather complex.

    Instead of a subsubform just to return a single value, a domain aggregate function might be simpler, no macro or VBA. Could be a DLookup() in a textbox on subform, like:

    =DLookup("TicketVar", "[Adm-TicketVar]", "OpDate=#" & [OpDate] & "# AND [Bag Number]='" & [Bag Number] & "'")

    The [Bag Number] field is set as a text type. This means the sorting will be by alpha rules, not numeric. Ex:

    1
    11
    2
    285
    3
    etc

    Unless you use Format() function to force placeholder zeros, Format([Bag Number], "0000"), which will output like:

    0001
    0002
    0003
    0011
    0285
    etc
    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.

  2. #17
    RankSinatra is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Feb 2018
    Posts
    14
    That DLookup function is going to save me a lot of time. Unfortunately, it has the same issue as the subform did: changing the textbox numbers that reference values being added by the query seems to affect the new DLookup textbox, but the number itself does not change until the form is closed and reopened. Why are these subforms so difficult? Everyone else does uses the requery function.

  3. #18
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Okay, the calculation won't update until the record is committed to table. Record is committed when: 1) move to another record or 2) close table/query/form or 3) run code to save.

    So maybe you will need some code. The real trick is figuring out what event(s) to put it into. If you want the data to update after input into every textbox, then the AfterUpdate event of every textbox would have to run code to save the record. One syntax for committing record is:

    If Me.Dirty Then Me.Dirty = False

    Rats! Just did some testing. The domain aggregate calc in textbox is not updating the value. This might also require a Refresh on the other subform. But that is not as complicated as having to reference a subsubform.

    Me.Parent.[other subform container name].Requery

    But let's look at code to refresh subsubform anyway. Should be like:

    Me.Parent.[other subform container name].Form.[subsubform container name].Requery

    I did get that subsubform version to work with your db.
    Code:
    If Me.Dirty Then Me.Dirty = False
    Me.Parent.AdmOSalesEntry.Form.AdmOTicketVar.Requery
    Last edited by June7; 02-17-2018 at 11:18 PM.
    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. #19
    RankSinatra is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Feb 2018
    Posts
    14
    That works flawlessly, and adding the requery function after those on the other report solves the issue for the other subform. Thank you.

  5. #20
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Some suggestions:
    I would fix the naming issues (fields, tables, queries)
    I really don't like the compound PKs. See Microsoft Access Tables: Primary Key Tips and Techniques
    It looks like you have designed the tables like the spreadsheet; this actually has a name. It is termed "Committing spreadsheet" and is a non-normalized design.
    For instance, will you ever have more than 5 entries (OutStart6 or OutStart7)? If yes, then it means you will have to redesign your fields, tables, queries, forms, reports and possible code because you do not have a normalized structure.


    Looking at table "Adm48+", you could set the default value of the number fields to 0 (zero). Any NEW record would automatically have a value of 0, so the number field (in a new record) would never be NULL. Therefore you would not have to have very long IIF() functions.

    But every field/control would have a 0 displayed. If you don't want to see the zeros, there is another alternative: you could use the NZ() function. This function changes a NULL to what ever you decide you want. In the form "AdmOBalance" you have a control named "TotalIssued".
    The control source is
    Code:
    =IIf(IsNull([TotalIssued1]) And IsNull([TotalIssued2]) And IsNull([TotalIssued3]) And IsNull([TotalIssued4]) And IsNull([TotalIssued5]),Null,IIf(IsNull([TotalIssued1]),0,[TotalIssued1])+IIf(IsNull([TotalIssued2]),0,[TotalIssued2])+IIf(IsNull([TotalIssued3]),0,[TotalIssued3])+IIf(IsNull([TotalIssued4]),0,[TotalIssued4])+IIf(IsNull([TotalIssued5]),0,[TotalIssued5]))
    Whew!!! Using the NZ() function, you would have
    Code:
    =NZ([TotalIssued1],0) + NZ([TotalIssued2],0) + NZ([TotalIssued3],0) + NZ([TotalIssued4],0) + NZ([TotalIssued5],0)
    If the field "TotalIssued1" is NULL, the function will return a 0 (zero) instead of a NULL.



    And in the query "Adm+Calcs", there is a calculated field "UsageAdmO"
    Code:
    UsageAdmO: (IIf(IsNull([TotalIssued1]) And IsNull([TotalIssued2]) And IsNull([TotalIssued3]) And IsNull([TotalIssued4]) And IsNull([TotalIssued5]),Null,IIf(IsNull([TotalIssued1]),0,[TotalIssued1])+IIf(IsNull([TotalIssued2]),0,[TotalIssued2])+IIf(IsNull([TotalIssued3]),0,[TotalIssued3])+IIf(IsNull([TotalIssued4]),0,[TotalIssued4])+IIf(IsNull([TotalIssued5]),0,[TotalIssued5])))-(IIf(IsNull([TotalReturned1]) And IsNull([TotalReturned2]) And IsNull([TotalReturned3]) And IsNull([TotalReturned4]) And IsNull([TotalReturned5]),Null,IIf(IsNull([TotalReturned1]),0,[TotalReturned1])+IIf(IsNull([TotalReturned2]),0,[TotalReturned2])+IIf(IsNull([TotalReturned3]),0,[TotalReturned3])+IIf(IsNull([TotalReturned4]),0,[TotalReturned4])+IIf(IsNull([TotalReturned5]),0,[TotalReturned5])))
    This could be replaced with
    Code:
    UsageAdmO: (NZ([TotalIssued1],0) + NZ([TotalIssued2],0) + NZ([TotalIssued3],0) + NZ([TotalIssued4],0) + NZ([TotalIssued5],0)) - (NZ([TotalReturned1],0) + NZ([TotalReturned2],0) + NZ([TotalReturned3],0) + NZ([TotalReturned4],0) + NZ([TotalReturned5],0))
    (a lot shorter)



    Good luck with your project...

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 06-14-2017, 02:10 PM
  2. Replies: 6
    Last Post: 03-09-2016, 12:41 PM
  3. Form Information from multiple tables.
    By Homegrownandy in forum Access
    Replies: 1
    Last Post: 08-27-2015, 05:20 AM
  4. Large Quantity Of Data
    By dr4ke in forum Queries
    Replies: 3
    Last Post: 01-18-2013, 11:19 AM
  5. Replies: 1
    Last Post: 12-18-2012, 02:50 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