Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Compile Error - Argument Not Optional

Posted on 2004-10-28
3
Medium Priority
?
303 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
Comment
Question by:bakerdj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 34

Expert Comment

by:flavo
ID: 12434057
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:
Bat17 earned 500 total points
ID: 12434081
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
ID: 12434431
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

597 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