Please explain what is in tblGoals. Without more
information, I have had to assume that there is only one
record (with one field).
Your code below looks up the value in the RecruitMessages
field in the first (only?) record, assigns it to a **local**
variable, and then exits (which discards the local
variable). Because of your use of a local variable, the
procedure has no effect on anything in your application.
The Open event may, or may not, be an appropriate place to
do this. It depends on what your objective for the dMsgGoal
variable happens to be.
Lacking all that important information, you might(?) make
more progress using:
Dim dMsgGoal As Integer 'daily recruiting message goal
Private Sub Form_Open(Cancel As Integer)
dMsgGoal = DLookup("RecruitMessages", "tblGoals") / 20
End Sub
I have not gotten far on this test form I am building (is i t because it is a
Form_Open?):
Private Sub Form_Open(Cancel As Integer)
'Dim MaxCallTime As Integer 'Maximum minutes in call period
'Dim CallStartTime As Integer 'When does calling start
Dim dMsgGoal As Integer 'daily recruiting message goal
dMsgGoal = DLookup("RecruitMessages", "tblGoals", "")
'MaxCallTime = 210 'Max minutes: 8:30AM to noon
End Sub
:
If that's the line with the error, the error message means
that tblGoals has a null value in the Messages field or that
tblGoals has no records.
If that's not the line with the error, then I can't guess
without seeing the rest of the procedure.
Rod wrote:
dMsgGoal = DLookup("Messages", "tblGoals").
dMsgGoal as Integer.
:
That might be a useful clue if I could see the code that you
used when you got that error and you identified the line
that Access complained about.
Making some guesses, dMsgGoals is declared as a Double, you
used DLookup and it didn't find anything so it returned
Null, which can not be stored in anything other than a
Variant.
Rod wrote:
I think we are getting somewhere. The new error is "Invalid use of null."
Messages is of type integer with a value of 1000.
Rod wrote:
I have a linked table tblGoals, which has [Messages] of type integer. I am
simply trying to assign
dMsgGoals = [tblGoals].[Messages]/20.
Currently, Messages = 1000. I am expecting dMsgGoals to be assigned 50.
I think my syntax is off because I keep getting "Access can't find the field
"|" referred to in your expression."