use condition to determine whether or not to update tbl

  • Thread starter Thread starter Nichole
  • Start date Start date
N

Nichole

I have two tables. One is current year, the other is
prior years. I need to append current year to prior years
based on results from a msgbox. I have the logic written
out, but need to get it into workable code.

If MaxPriorYr = CurrentYr Then
MsgBox("You have already archived this year. _
Do you want to replace it?", vbYesNo) As VbMsgBoxResult
If VbMsgBoxResult = True Then
DoCmd.OpenQuery (delete "old" current yr info)
DoCmd.OpenQuery (append "new" current yr info)
Else: DoCmd.CancelEvent
End If
Else: DoCmd.OpenQuery (append "new" current yr info)
End If

Any help would be greatly appreciated.
 
I have two tables. One is current year, the other is
prior years.

Storing data in tablenames IS A BAD IDEA for this very reason.
I need to append current year to prior years
based on results from a msgbox. I have the logic written
out, but need to get it into workable code.

If MaxPriorYr = CurrentYr Then
MsgBox("You have already archived this year. _
Do you want to replace it?", vbYesNo) As VbMsgBoxResult
If VbMsgBoxResult = True Then
DoCmd.OpenQuery (delete "old" current yr info)
DoCmd.OpenQuery (append "new" current yr info)
Else: DoCmd.CancelEvent
End If
Else: DoCmd.OpenQuery (append "new" current yr info)
End If

Any help would be greatly appreciated.

Without knowing the structure of your tables, what identifies "old
current yr info" and "new current yr info", I'd have no specific
suggestions. How are these values stored in your table? Have you
defined MaxPriorYr and CurrentYr elsewhere in your code? What
datatype?
 
Back
Top