K
kft10 via AccessMonster.com
Hi
I am trying to write VBA script in Access 2003 like this:
Private Sub ProgramList_AfterUpdate()
Dim prog As Variant
Dim stYTD As Variant
If Me.ProgramList = 1 Then prog = "JPAAF" Else If Me.ProgramList = 2 Then
prog = "JPAAE" Else If Me.ProgramList = 3 Then prog = "JPAAH" Else If Me.
ProgramList = 4 Then prog = "JPABX" Else If Me.ProgramList = 5 Then prog =
"JPABR" Else If Me.ProgramList = 6 Then prog = "JPAAW" Else If Me.ProgramList
= 7 Then prog = "JPAAT" Else If Me.ProgramList = 8 Then prog = "JPABS" Else
If Me.ProgramList = 9 Then prog = "JPABK" Else If Me.ProgramList = 10 Then
prog = "JPAA3" Else If Me.ProgramList = 11 Then prog = "JPAA1" Else If Me.
ProgramList = 12 Then prog = "JPABA" Else prog = "JPAAI"
stYTD = DLookup("[Start_Date]", "[Projection]", _
"[Program_Code] = " & prog)
End Sub
Notes: [Start_date] and [Program_code] are 2 field in Projection table.
But Access alway gives me an error message says 'you cancelled the previous
operation'. Is anyone in forum can fix my script? Thank in advance.
Rgds,
KF
I am trying to write VBA script in Access 2003 like this:
Private Sub ProgramList_AfterUpdate()
Dim prog As Variant
Dim stYTD As Variant
If Me.ProgramList = 1 Then prog = "JPAAF" Else If Me.ProgramList = 2 Then
prog = "JPAAE" Else If Me.ProgramList = 3 Then prog = "JPAAH" Else If Me.
ProgramList = 4 Then prog = "JPABX" Else If Me.ProgramList = 5 Then prog =
"JPABR" Else If Me.ProgramList = 6 Then prog = "JPAAW" Else If Me.ProgramList
= 7 Then prog = "JPAAT" Else If Me.ProgramList = 8 Then prog = "JPABS" Else
If Me.ProgramList = 9 Then prog = "JPABK" Else If Me.ProgramList = 10 Then
prog = "JPAA3" Else If Me.ProgramList = 11 Then prog = "JPAA1" Else If Me.
ProgramList = 12 Then prog = "JPABA" Else prog = "JPAAI"
stYTD = DLookup("[Start_Date]", "[Projection]", _
"[Program_Code] = " & prog)
End Sub
Notes: [Start_date] and [Program_code] are 2 field in Projection table.
But Access alway gives me an error message says 'you cancelled the previous
operation'. Is anyone in forum can fix my script? Thank in advance.
Rgds,
KF