Page 2 of 2 FirstFirst 12
Results 16 to 28 of 28
  1. #16
    ZJGMoparman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    24

    I am using a very similar query to the one from post 4. I'm using the dmax function to find the Max last updated date. For some reason when I run the query it is showing more than one record for the same battery. Shouldnt dmax only sbow the record corresponding to the maximum date?

  2. #17
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,960
    Similar is not the same and the two queries are really very different.

    My suggested query uses DMax in WHERE clause. Your query uses Max and no filter criteria. DMax and Max work differently.
    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. #18
    ZJGMoparman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    24
    I have now created a separate query to calculate the total flight time and average flight time for each battery. For some reason when I run the query I am getting separate results for some batteries. For example: Battery 17 has two flights. When I run the query it shows two lines for battery 17... as if it is treating them as two different batteries.The other batteries seem to be working fine... at least with the test data I am using.

  4. #19
    ZJGMoparman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    24
    I should add that the sql of the query I am using is:

    SELECT tblBattery.BatteryID, DMax("SessionDate","qryLinkSession-Flight","Battery=" & [BatteryID]) AS RecentUse
    FROM tblBattery INNER JOIN tblFlight ON tblBattery.BatteryID = tblFlight.Battery
    ORDER BY tblBattery.BatteryID;

  5. #20
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,960
    I am getting lost. What is it you are trying to do?

    Have you tested the exact queries I provided in post 4?
    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. #21
    ZJGMoparman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    24
    I have tested those queries. They seemed to work as long as the flight date and charge date are on separate days. The query I asked about most recently is for something else. The most recent query I asked about is only supposed to calculate total time and averageflight time for each battery.

  7. #22
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,960
    From what I understand of your data, the queries I suggest for the comboboxes work properly even if flights and charging are on same date.

    Query for total and average flight times for each battery is an aggregate query, try:

    SELECT tblBattery.BatteryID, Sum(Val(Left(Nz([FlightTime],"00"),2))+Val(Mid(Nz([FlightTime],"00:00"),3,2))/60) AS TotMinutes, Avg(Val(Left(Nz([FlightTime],"00"),2))+Val(Mid(Nz([FlightTime],"00:00"),3,2))/60) AS AvgMinutes
    FROM tblBattery LEFT JOIN tblFlight ON tblBattery.BatteryID = tblFlight.Battery
    GROUP BY tblBattery.BatteryID;
    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. #23
    ZJGMoparman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    24
    The totals and average query works exactly like I wanted. I just added a round function to round to 2 decimal Places.

    The control source queries from post 4 are not working on my end. Query1 displays all of the flights for each battery with the corresponding date which is right. The other two queries are listing every single battery now.

  9. #24
    ZJGMoparman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    24
    Actually let me update what I just said. Only the flightentry query is showing every battery. The charge entry query shows nothing.. no matter what kind of test data i eneter, nothing changes.

  10. #25
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,960
    Try this for the ChargeEntry query:

    SELECT tblBattery.BatteryID
    FROM tblBattery
    WHERE (((Nz(DMax("ChargeDate","tblCharge","Battery=" & [BatteryID]),#1/1/2000#))<Nz(DMax("SessionDate","qryFlightTime","Bat tery=" & [BatteryID]),Date())) AND (Not (DMax("SessionDate","qryFlightTime","Battery=" & [BatteryID])) Is Null));
    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. #26
    ZJGMoparman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    24
    Alright, I now have both the ChargeSource and Flightsource queries working like I want. I modified a few things from what you suggested June because I added another criteria for the battery to show up. Now I have a subform nested in the session form that I can enter the flights under that session. The subform is displayed in datasheet view. I would like to have a requery that will update the flightsource combo box list once I use one of the batteries. Since I will be having multiple flights per session, I don't want to accidentally enter the same battery in more than one flight.

  12. #27
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,960
    Commit the record to table then requery the combobox.

    Record is committed when form closes, move to another record, or with code.

    So in the form Current event:
    Me.comboboxname.Requery
    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. #28
    ZJGMoparman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    24
    Thank you June. That worked perfect! I'm slowly learning Access. I still have a load I would like to add to my database, but it is coming together. I would like to add graphs and reports for the batteries, flights, and aircraft, but I am not to that point yet nor do I know how. I will need to start reading when I get to that stage.

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

Similar Threads

  1. Needing help with database setup.
    By roger123 in forum Access
    Replies: 3
    Last Post: 06-21-2012, 08:21 AM
  2. New Database Setup
    By sirwalterjones in forum Access
    Replies: 3
    Last Post: 12-14-2011, 08:38 PM
  3. Help database setup please!
    By clzhou in forum Access
    Replies: 4
    Last Post: 07-10-2011, 11:30 PM
  4. RE: Web database setup
    By abarin in forum Database Design
    Replies: 2
    Last Post: 05-31-2011, 05:47 PM
  5. Need help with database setup
    By ctyler in forum Database Design
    Replies: 6
    Last Post: 08-30-2010, 01:35 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