Results 1 to 2 of 2
  1. #1
    shariq1989 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    50

    Use cmd button to fill textbox


    I have a form "Maintenance Completed", where there is a text box to enter the engine hours when the maintenance was completed. The users select an engine, a component, enter engine hours and a date.The users are entering the hours in manually but I am trying to write a code for an "estimate" button. The button would "grab" the engine hours from TblHourEntry based on the EngineID selected in the form. Then it would use the date entered into the form in the following equation:

    ((Date/30)*AvgMonthlyHours (from a query based on engineID)) + MaxofEngineHours(from TblHourEntry based on engineID)

    The user can then, either choose to go with the estimated value or go get actual readings and compare them to the estimated to verify accuracy of the estimate.

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    What you describe can be done. You would assign the result of the calculation to the control. The domain aggregate functions will be needed (DAvg() & DMax I assume)

    me.controlname=(Date()/30)*DAvg("hoursfield","queryname","EngineID=" & me.engineIDcontrolname) + DMax("hourfield","tblHourEntry","EngineID=" & me.engineIDcontrolname

    The me. notation is just a shorthand for the current form. The above assumes that the EngineID field in the query/table is a numeric data type field. If the query already calculates the avg. monthly hours, then I would substitute the DLookup() function in place of the DAvg() function. I'm not sure what you hope to get out of the Date/30 part of the expression.

    Without more info on how the tables & queries you mention are structured, the above expression is just a guide. Hopefully it helps

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

Similar Threads

  1. Replies: 17
    Last Post: 02-08-2012, 10:06 AM
  2. Fill data entry textbox with variable
    By broecher in forum Forms
    Replies: 6
    Last Post: 11-18-2011, 07:54 PM
  3. Replies: 5
    Last Post: 09-14-2011, 03:41 PM
  4. Replies: 1
    Last Post: 10-31-2010, 12:01 AM
  5. Button to fill txt box with "Now ()"
    By viper in forum Forms
    Replies: 2
    Last Post: 10-14-2010, 10: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