Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2012
    Posts
    1

    Unanswered: Access 2003 Form

    I have a form that will be used for data entry. on the form i have current metrics and proposed metrics that will be entered in by the user. I also have another set of metrics that will be used to calculate the difference between the current and proposed.
    I want the diff metrics to auto populate.
    here is the code i have so far:

    Private Sub ttl_trans_cost_future_Exit(Cancel As Integer)


    Set frm_project = dbs.OpenForm("Form!frm_project_entry")

    sql = "SELECT ([cpm_future]-[cpm_current])/1 AS cpm,([WAD_future]-[WAD_current])/1 AS WAD,([del_freq_future]-[del_freq_current])/1 AS del_freq,([no_trips_future]-[no_trips_current])/1 AS no_trips,([MT_miles_future]-[MT_miles_current])/1 AS MT_miles,([total_miles_future]-[total_miles_current])/1 AS total_miles,([Stops_future]-[Stops_current])/1 AS Stops,([bill_stops_future]-[bill_stops_current])/1 AS bill_stops,([trailers_future]-[trailers_current])/1 AS trailers,([hours_future]-[hours_current])/1 AS hours,([ttl_trans_cost_future]-[ttl_trans_cost_current])/1 AS ttl_trans_cost"
    sql = sql & "FROM tbl_project_list "
    Set operation = dbs.OpenRecordset(sql)
    Set operation = dbs.OpenForm(sql)

    frm_project("cpm_diff") = operation("cpm")
    frm_project("wad_diff") = operation("wad")
    frm_project("del_freq_diff") = operation("del_freq")
    frm_project("no_trips_diff") = operation("no_trips")
    frm_project("mt_miles_diff") = operation("mt_miles")
    frm_project("total_miles_diff") = operation("total_miles")
    frm_project("stops_diff") = operation("stops")
    frm_project("bill_stops_diff") = operation("bill_stops")
    frm_project("trailers_diff") = operation("trailers")
    frm_project("hours_diff") = operation("hours")
    frm_project("ttl_trans_cost_diff") = operation("ttl_trans_cost")


    Form!frm_project_entry.Update
    operation.Close

    End Sub

    I get an error "Object required" when the above code is ran.
    Any help would be appreciated.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    lets get out the crystal ball and guess the line.. or perhaps you coudl makje it easier by identifying waht line reports the error
    what steps you have takewn to debug tghe code and try and work out why it is going wrong.
    this error usually occurs when you are trying to assign a value to an object, that could be:-
    you are trying to assign a value using the default property with an incompatible value
    you are trying to assign a value on an object that isn't open
    you are trying to assign an invalid value
    you are not explcitly referring to an object or method.

    my guess is its going to be failing on
    frm_project("cpm_diff") = operation("cpm")
    what I'd expect to see is something like
    forms!frm_project!cpm_diff.value = operation!cpm



    there are some oddities in your code eg the division by 1 in the SQL
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •