I'm having a really strange problem and wonder if anyone can help me. Here's my table structure:
tblTV
TvAgentNumber (PK long integer)
TVStartWeek (short form date)
tblNewBus
AgentNumber (PK long integer...related to tblTV)
01-Jan-03 (Weeks with long integer data)
08-Jan-03
....
What I'm trying to do is use the DateAdd function to manipulate the TVStartWeek and then reference this output to a quantity in the weekly fields of the other table. Here is the VB I have constructed:
Function DateChange(StartDate As Variant, AdAgentNumber As Variant)
Mth1 = "[tblNewBus].[" & CStr(Format(DateAdd("d", -7, StartDate), "dd-mmm-yy"
) & "]"
Mth1Sls = DSum(Mth1, "tblNewBus", "[tblNewBus].[AgentNumber]=" & AdAgentNumber)
DateChange = (Mth1Sls)/2
When I do this, I am getting an error message that says:
Runtime error 2001: You cancelled the previous operation.
I cannot for the life of me figure out what is wrong with my VB. When I take out the Mth1Sls line, and make DateChange=Mth1, it outputs the right [tblNewBus].[date] reading for all my fields in the query, but it breaks down in the Mth1Sls part. Does anyone have any ideas on how to fix this? I'm really at my wits end.
Thank you,
jeff
tblTV
TvAgentNumber (PK long integer)
TVStartWeek (short form date)
tblNewBus
AgentNumber (PK long integer...related to tblTV)
01-Jan-03 (Weeks with long integer data)
08-Jan-03
....
What I'm trying to do is use the DateAdd function to manipulate the TVStartWeek and then reference this output to a quantity in the weekly fields of the other table. Here is the VB I have constructed:
Function DateChange(StartDate As Variant, AdAgentNumber As Variant)
Mth1 = "[tblNewBus].[" & CStr(Format(DateAdd("d", -7, StartDate), "dd-mmm-yy"
Mth1Sls = DSum(Mth1, "tblNewBus", "[tblNewBus].[AgentNumber]=" & AdAgentNumber)
DateChange = (Mth1Sls)/2
When I do this, I am getting an error message that says:
Runtime error 2001: You cancelled the previous operation.
I cannot for the life of me figure out what is wrong with my VB. When I take out the Mth1Sls line, and make DateChange=Mth1, it outputs the right [tblNewBus].[date] reading for all my fields in the query, but it breaks down in the Mth1Sls part. Does anyone have any ideas on how to fix this? I'm really at my wits end.
Thank you,
jeff