I'm trying to assign a value of a variable in a table or query to a variable in a VBA Module. The reason that I'm doing it this way is because long and multiple calculations that follow so doing with macros or queries won't do the trick.
I keep getting errors.
The Table has the following fields:
Date
one
two
three
four
five
This is my code
////////////////////////////////////////////////////
Function StartSimulation()
On Error GoTo StartSimulation_Err
Dim xone As Integer
Dim xtwo As Integer
Dim xthree As Integer
Dim xfour As Integer
Dim xfive As Integer
DoCmd.OpenQuery "query1", acViewNormal, acReadOnly
DoCmd.GoToRecord acQuery, "Query1", acFirst
' With CodeContextObject
xone = !one
' End With
DoCmd.Minimize
DoCmd.OpenForm "Results", acNormal, "", "", , acReadOnly
StartSimulation_Exit:
Exit Function
StartSimulation_Err:
MsgBox Error$
Resume StartSimulation_Exit
End Function
///////////////////////////////////////////////////
With the 'With' statement in I get this error:
Microsoft access can't find the field 'one' referred to in your expression:
Without the 'With' statement I get this error:
Invalid or unqualified reference.
I keep getting errors.
The Table has the following fields:
Date
one
two
three
four
five
This is my code
////////////////////////////////////////////////////
Function StartSimulation()
On Error GoTo StartSimulation_Err
Dim xone As Integer
Dim xtwo As Integer
Dim xthree As Integer
Dim xfour As Integer
Dim xfive As Integer
DoCmd.OpenQuery "query1", acViewNormal, acReadOnly
DoCmd.GoToRecord acQuery, "Query1", acFirst
' With CodeContextObject
xone = !one
' End With
DoCmd.Minimize
DoCmd.OpenForm "Results", acNormal, "", "", , acReadOnly
StartSimulation_Exit:
Exit Function
StartSimulation_Err:
MsgBox Error$
Resume StartSimulation_Exit
End Function
///////////////////////////////////////////////////
With the 'With' statement in I get this error:
Microsoft access can't find the field 'one' referred to in your expression:
Without the 'With' statement I get this error:
Invalid or unqualified reference.