Hiya all
In my database i am linking to tables from external databases for criteria set up on a form editied by the user. My code can successfully link the tables but if it cannot find the requested table it crashes. I tried putting in the following error trap which seems to work for the first On Error but not for the second. The code seems to skip the second On Error statement and goes straight to informing the user that the table could not be linked and cancels my code.
Below is a sample of the code i am trying to use, i have defined all the parts before the snippet and display a message box after the snippet but thought these were not needed below.
THANKS IN ADVANCE!
Code Example:
LinkTMR:
TMR = "TMRWk" & Right(Forms![Latest Week]!_
[MaxOfTmr Week No], 4)
On Error GoTo TMRError
DoCmd.TransferDatabase acLink, "Microsoft Access",_
"s:\tmr\tmr.mdb", acTable, TMR, "TMRWk", False
TMR = 0
GoTo LinkBP
TMRError:
TMR = 1
LinkBP:
BP = "Wk" & Right(Forms![Latest Week]!_
[MaxOfbp Week No], 4)
On Error GoTo BPerror
DoCmd.TransferDatabase acLink, "Microsoft Access", _
"s:\bp\bp.mdb", acTable, BP, "BPWk", False
BP = 0
GoTo DoneWk
BPerror:
BP = 1
Done Wk = BP + TMR
![[pc3] [pc3] [pc3]](/data/assets/smilies/pc3.gif)
Adam![[glasses] [glasses] [glasses]](/data/assets/smilies/glasses.gif)
In my database i am linking to tables from external databases for criteria set up on a form editied by the user. My code can successfully link the tables but if it cannot find the requested table it crashes. I tried putting in the following error trap which seems to work for the first On Error but not for the second. The code seems to skip the second On Error statement and goes straight to informing the user that the table could not be linked and cancels my code.
Below is a sample of the code i am trying to use, i have defined all the parts before the snippet and display a message box after the snippet but thought these were not needed below.
THANKS IN ADVANCE!
Code Example:
LinkTMR:
TMR = "TMRWk" & Right(Forms![Latest Week]!_
[MaxOfTmr Week No], 4)
On Error GoTo TMRError
DoCmd.TransferDatabase acLink, "Microsoft Access",_
"s:\tmr\tmr.mdb", acTable, TMR, "TMRWk", False
TMR = 0
GoTo LinkBP
TMRError:
TMR = 1
LinkBP:
BP = "Wk" & Right(Forms![Latest Week]!_
[MaxOfbp Week No], 4)
On Error GoTo BPerror
DoCmd.TransferDatabase acLink, "Microsoft Access", _
"s:\bp\bp.mdb", acTable, BP, "BPWk", False
BP = 0
GoTo DoneWk
BPerror:
BP = 1
Done Wk = BP + TMR
![[pc3] [pc3] [pc3]](/data/assets/smilies/pc3.gif)
Adam
![[glasses] [glasses] [glasses]](/data/assets/smilies/glasses.gif)