bakerdj
asked on
Compile Error - Argument Not Optional
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
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