Solved

Compile Error - Argument Not Optional

Posted on 2004-10-28
285 Views
Last Modified: 2012-06-27
I'm testing some code to send field info into variables.  All come in except one [Load].  I've got another textbox to display the value without any problem, but the code will not compile when I assign the value to a variable.  If I comment the line out then it compiles OK.
The code is as follows:

Private Sub cboCurrentRte_AfterUpdate()

Dim rst As Recordset, strCriteria As String
Dim strRte, strAMoutW, strAMoutGr, strAMoutMd, strAMoutStrt As String
Dim dbInside, dbObt, dbRefuel, dbLoad, dbObtVal, dbHH, dbUC, dbSpecAssist As Double

    strCriteria = "[RES_ROUTE] = '" & Me.cboCurrentRte & "'"
    Set rst = Me.RecordsetClone
    rst.FindFirst strCriteria
    If rst.NoMatch Then
        MsgBox ("Not Updated")
    Else
        Me.Bookmark = rst.Bookmark
    End If
       
    strRte = [RES_ROUTE]
    dbInside = [LcInside]
    dbObt = [Obtain]
    dbRefuel = [Refuel]
   
    dbLoad = 0.89
    dbLoad = [Load]    '<<< error occurs here - Load is highlighted and the compiler stops at the AfterUpdate line
    dbObtVal = IIf(Nz(dbObt) = 0, 0, (Nz(dbObt) + Nz(dbLoad) + 5))
    dbHH = [HHval]
    dbUC = [CUCT]
    dbSpecAssist = PlusMinus([SPECTAM], [ASSISTAM])
   
    'MsgBox (Str(dbInside))
    'Me.txtHH.SetFocus
     Me.txtR2hh = dbInside + 1000
       
End Sub
0
Question by:bakerdj
    3 Comments
     
    LVL 34

    Expert Comment

    by:flavo
    1st thing

    Dim rst As Recordset, strCriteria As String
    Dim strRte, strAMoutW, strAMoutGr, strAMoutMd, strAMoutStrt As String
    Dim dbInside, dbObt, dbRefuel, dbLoad, dbObtVal, dbHH, dbUC, dbSpecAssist As Double

    cant do this..

    this line for example will return

    Dim strRte, strAMoutW, strAMoutGr, strAMoutMd, strAMoutStrt As String

    varriant,   varriant,      varriant,      varriant,        string

    You should do them all on seperate lines like

    dim a as string
    dim b as string etc...

    .Net you can do this, VBA you cant.


    You clould try

    dbLoad = Me.[Load].Value

    Dave
    0
     
    LVL 9

    Accepted Solution

    by:
    I think that you have run foul of a Reserved Word in Access, try renaming the field to txtLoad and see what happens

    Peter
    0
     

    Author Comment

    by:bakerdj
    Peter,

    I changed the field name to AMload and it works.  I searched help in Access and VB and LOAD is a statement in VB.

    thanks

    Dennis
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
    Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
    Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
    With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

    856 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now