Results 1 to 13 of 13
  1. #1
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194

    Making a Dlookup answer fill in a table field..

    Another question!!!





    So I have my Table with Customers on it, one field is Date Collected. Another is Frequency of pickup (weekly, fortnightly, Monthly)

    In my form I use

    Next Pickup is
    Code:
    Source = [Last Collected]+DLookUp("Days","PackingFreqT","FreqID=" & [PackFreq])
    Now this works!
    Therefore if the customer has Fortnight as their Frequency, the calculation takes "previous collected date", adds 14 to it (by looking up 14 as the correct number for Fortnight) and then returns the new date for a next expected pickup..

    HOWEVER this information is all in a form.. I want this to be in my table, and update my table value every time i change "last collected"

    how do i make a form value go to my table if the control source already has a calculation in it?

    Or am i doing this the COMPLETELY wrong way..?

    Glenn

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Why do you need to save this calculated value? The 'next pickup date' is a dynamic value. It is a projected event. It should be calculated as needed. It doesn't need to be saved. What you save is the actual pickup date when it occurs.

    Saving calculated values requires code - macro or VBA.
    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
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    i want to save the calculated value onto the table so that i can use the table to create a report of all Pateints that have their NEXT pickup date in the next 3 days,

    Therefore I need to take last pickup date + the value from their pickup frequency and then take that away from todays date.
    Then i was going to make a query on that table with constraints of "show if pickup date is <3" or... at least that was my idea.

    Therefore i can make reports and stuff for pharmacies that shows when to start packing the next patients packs.

    I wouldnt be surprised if im doing this the wrong way though. sorry!

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Normally, the rule is: "you dont save calculated values....you calculate them."
    This is what queries are for.
    Your query will have a field that does the calculation..that way its ALWAYS live & fresh.

    Use queries , not DLOOKUPS.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    As ranman says, do calc in query and use query for report.

    If you save the value, risk data getting 'out of sync'.
    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
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    Awesome! I did it
    So i created a query with calcs in it and an IIF expression and got it working,
    Then created a form based around that query!

    SO i have gotten to the stage that i have customers listed that require packs to be made within the next 3 days.

    What i want to do is add an "edit customer" button (as i have locked the cells on this form) which brings up my edit customer form.

    My edit customer form relys on stating values "Forms!SearchPxF!FirstName" and "Forms!SearchPxF!FirstName"

    So I want the above value to collect the data from [Firstname] and use it for "Forms!SearchPxF!FirstName" HOWEVER since i have a number of patients per page it doesnt know which [firstname] box to use the information from....

    How can i specific which record the button points to since there are multiple records on the form?

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The code will use value from record that has focus.

    Instead of searching on names, should probably search on customer 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
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    k ill try that, so i could put something like...radio dots or something to help with "choosing focus"?
    And ill put ID in front of names but not shown

  9. #9
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    still getting "the field [Firstname] could refer to more than one table listed in the FROm clause of your SQL statement

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Whatever cues user needs in order to understand record must be selected.

    The query has multiple tables with field named [Firstname]? Need to include table name as qualifier.

    [tablename].[Firstname]

    Post the query SQL statement for analysis.
    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.

  11. #11
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    Hi again

    I dont know how to find the SQL statement?

    But also, All data is from the same table.

    Table = CustomerInfoT
    Query = CustomerPacksQ

    I want to add a button for EACH LINE at the end of the line that says "edit Patient" and when you clik on it it opens "PatientInfoF" Form for THAT patient

    Click image for larger version. 

Name:	daystopack.jpg 
Views:	7 
Size:	56.1 KB 
ID:	16802Click image for larger version. 

Name:	pxinfo.jpg 
Views:	7 
Size:	84.3 KB 
ID:	16803

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Open query in design view then switch to SQL view. That is the SQL statement.

    Seems buttons don't work well for that. If I remember right, clicking the button doesn't actually put focus on the record (doesn't select the record). Better to use a textbox and its Click event.
    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.

  13. #13
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    ahhh ok thanks Seems a bit weird! So the text box would be part of that Record on that form?

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

Similar Threads

  1. Auto-fill one field from another table
    By tasoper in forum Access
    Replies: 3
    Last Post: 06-13-2014, 07:17 AM
  2. Replies: 3
    Last Post: 03-07-2014, 10:39 AM
  3. Replies: 1
    Last Post: 11-04-2011, 06:53 AM
  4. Replies: 5
    Last Post: 01-20-2011, 11:36 PM
  5. Replies: 2
    Last Post: 11-17-2006, 01:07 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