Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    setting value for bound controls (2000 all updates

    Hans
    On my fsubProjects form, 2 of the controls are PSTRate and GSTRate, and these are bound to tblProjects.

    Trouble is those values are subject to being changed by the governments, and so are date-specific. In their respective tables, tblPST and tblGST, I have a StartDate and EndDate for their values.

    I wanted to store the values for those tax rates in the Projects table, so that a record always held the correct values for those tax rates.

    At one point, I had the following code on the Current event for the form. That was causing problems, and you said that I should not set the value for bound controls.

    So I moved the code to the Dirty event, and it works there.

    <code>Dim curTemp as Currency
    Dim curTemp2 as Currency
    If Me.NewRecord Then
    curTemp = DLookup("PSTRate", "tblPST", "#" & Me.QuoteDate & "# Between StartDate And EndDate")
    curTemp2 = DLookup("GSTRate", "tblGST", "#" & Me.QuoteDate & "# Between StartDate And EndDate")
    Me.CurPSTRate = curTemp
    Me.CurGSTRate = curTemp2
    End If</code>

    Does that seem okay to you...or is there a better way to do this?

    Thanks.

    Tom

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: setting value for bound controls (2000 all updates

    Please don't direct questions at me personally - any Lounger can reply to questions, and I cannot always be online.

    As far as I can tell, there is no need to store the rates in the tblProjects table. You can always use a query to look up the values of PSTRate and GSTRate for the QuoteDate of a project. This ensures that you'll always get the correct values.

    If that slows down things too much, and you do need to store the rates in tblPRojects, I'd use the Before Insert event of the form instead of the On Dirty event. Before Insert occurs only in a new record, when the user starts entering data. It doesn't occur in existing records. So you don't have to check Me.NewRecord.

  3. #3
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: setting value for bound controls (2000 all upd

    I apologize for personally addressing my question. I knew better. (Also I might better have attached it to the end of the earlier post). I'll be more careful.

    The reason I wanted to pull the values into the Projects form, fsubProjects, was due to the following processing...
    1. Materials are added in a subform, fsubMaterials and Labour is added in another subform, fsubLabour
    2. The totals from the Materials and Labour subforms show in fsubProjects
    3. PST then shows in another text box (and PST is calculated on Materials only)
    4. GST also shows in another text box (and GST is calculated on both Materials and Labour)
    5. There are cases where the customer can be exempt from one or both taxes. If the user clicks the Exempt box the relevant tax shows as 0; otherwise is calculated and shown at its rate.
    6. The customer is required to make a Deposit equivalent to 50% of the total Quote for a project. This 50% is calculated in an additional text box at the bottom of the form.

    It could all be done without showing the tax on the form, but the user likes to see everything showing there. And this also affords the user the latitude of adjusting the Deposit from the 50% calculation if he so desires.

    I will switch to code to the Before Insert event and remove the check for new record.

    Thanks.

    Tom

Posting Permissions

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