Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    513

    with 'table'

    I thought that i had used 'with' to refer to values in a table


    where the table has only 1 record (and never more than 1)

    i have this:
    Code:
        With tbeCostAdderPCT 'valid table name 
            If .AdderPct_Tl_override Then 'valid field name  <-THIS IS WHERE THE ERROR OCCURS
                 ...
            Else
                dblAdderTl_MarkUps = (.MarkupPct_dist + .MarkupPct_contr) * (1 + dblAdderTl_Contingent) 'also valid names
                ....
    but i'm getting error "424": object required; which i don't think i had before (?)

    is this something that i had never been able to do? or am i missing something this time ?


    as always, with much appreciation in advance,
    m.

  2. #2
    jojowhite's Avatar
    jojowhite is online now Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    With should reference an object (form, report, control, recordset) that are currently active.

  3. #3
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    565
    It looks like you're trying to do logic to calculate one or more values... but why are you doing this in VBA? If you do it in a Query, you can do the entire column at a time. Unless you absolutely have to compute this one record at a time, I would do this in a query instead of in VBA. (I would say "do it in a query unless you can prove it won't work that way and you absolutely have to use a recordset to accomplish it")

  4. #4
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    513
    The table only has one record, so in effect, I do have to do this one record at a time =:-)
    NTL, it is in VBA rather than a query b/c much of the manipulation, beyond the snippet of code provided here, would be cumbersome in a query. That is to say, I'm going the VBA route, not b/c it would be the most efficient, but solely for my own sanity (!)
    _________________________________
    revised the code (in an obvious way...) to be per below (defining the table as a recordset); and all is good.
    (as an mentor of mine always said: "when all else fails... check the obvious"

    thnx,
    m.

    Code:
        Set gsRst = CurrentDb.OpenRecordset("SELECT * FROM tbeCostAdderPCT") '
        With gsRst
            If !AdderPct_tl_override Then
                ...
            Else
                dblAdderTl_MarkUps = (!MarkupPct_dist + !MarkupPct_contr) * (1 + dblAdderTl_Contingent)
                ...

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

Similar Threads

  1. Replies: 1
    Last Post: 03-08-2010, 02:32 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