I am getting an error in some code behind a form in a button click event. Here is the code:
The error is "Expecting =" in the line "ControlSaveNumcr("MindwireID", autol+1)".
I renamed the variable from autoid to autol (it's a long) and even changed the sub name from ControlSaveNum to ControlSaveNum2 and ControlSaveNumCR.
Here is the definition of ControlSaveNum.
Any ideas why I'm getting this error? It all looks ok and I don't think I'm using a reserved word in the wrong place.
Thanks.
Code:
Do While Not (Myset.EOF = True)
signtype = "C"
signsize = "11x7"
' Construct ItemID from PLU.
plu = ""
If (Len(Myset!Myplu) = 4) Then
plu = "PLU"
End If
If (Len(Myset!Myplu) = 0) Then ' Get auto id from Control table.
autol = ControlReadLong("MindwireID")
'zl = autol + 1
ControlSaveNumcr("MindwireID", autol+1) ' Error here
autol = Format(autoid, "00000") ' Use leading zeros.
plu = autol
End If
plu = plu & Myset!Myplu & signtype & "-" & signsize
s = plu & SEP
s = s & Myset!ProductClass & SEP
I renamed the variable from autoid to autol (it's a long) and even changed the sub name from ControlSaveNum to ControlSaveNum2 and ControlSaveNumCR.
Here is the definition of ControlSaveNum.
Code:
Public Sub ControlSaveNumCR(keyval As String, sval As Long)
' Save text in Control table. Saves values in a table like a registry.
' Control table has 2 fields: Name (string) and MyValue (long).
' keyval = Control record to save sval to.
' sval = value to save which corresponds to keyval.
Dim mydb As DAO.Database
Dim Myset As DAO.Recordset
Dim i As Integer, cnt As Integer, v As Variant
Dim crit As String ' criteria
On Error GoTo MyError
Set mydb = CurrentDb()
Set Myset = mydb.OpenRecordset("Control", dbOpenDynaset)
crit = "[Name] = '" & keyval & "'"
Myset.FindFirst crit
If Myset.NoMatch = True Then
MsgBox "ControlSaveNum: " & crit & ". Not found."
Else
Myset.Edit
Myset!MyValue = sval
Myset.Update
End If
v = SysCmd(acSysCmdSetStatus, " ")
SaveExit:
Myset.Close
mydb.Close
Set Myset = Nothing
Set mydb = Nothing
Exit Sub
MyError:
MsgBox "ControlSaveNum: ERROR " & Err.Number & " " & Err.Description
Resume SaveExit
Exit Sub
End Sub
Thanks.