Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code Assistance - LastUserUpdated & DateLastModified

Status
Not open for further replies.

FDBAdmin

Programmer
Apr 15, 2011
5
CA
Hello,

I have been having issues with some code in my DB. I have drastically changed the functions of the form (this was created by someone who is no longer here, so I am going into this blindly and the majority I think was created in "chunks" ---- Yuk).

I changed the location of the "LastUserUpdated & DateLastModified" fields onto tab view sheets. I also changed the code for the user popup box to confirm data edits. Since then these two functions are not working. Here is the snippet of my code that is giving me errors.

-------------------------- Begin Clip --------------------------

Private Sub DateLastModified_BeforeUpdate(Cancel As Integer)

End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Msg As String, Style As Integer, Title As String, DL As String
DL = vbNewLine & vbNewLine
Msg = "You have made changes to this record." & DL & _
"Are you SURE you want to save these changes?"
Style = vbQuestion + vbYesNo
Title = "ACCESS Database - Save Changed Data?"

If MsgBox(Msg, Style, Title) = vbNo Then
Cancel = True
Me.Undo
End If
DateLastModified = Now() 'will show date/time
UserLastUpdated = CurrentUser 'will show user who made a change
End Sub

--------------------------- End Clip ---------------------------

Any help would be appreciated. I am off work the next 4 days, but will check this from home. If you require more code or more information I will post a reply ASAP.

FDBAdmin

Adam W
London, Canada
 
How are ya FDBAdmin . . .

Your code always unpdates regardless yes/no. See correction below:
Code:
[blue]   If MsgBox(Msg, Style, Title) = vbNo Then
      Cancel = True
      Me.Undo
   [red][b]Else[/b][/red] [green]'vbYes[/green]
      DateLastModified = Now() 'will show date/time
      UserLastUpdated = CurrentUser 'will show user who made a change
   End If[/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
So now I am getting another error.

---------- code -----------

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Msg As String, Style As Integer, Title As String, DL As String
DL = vbNewLine & vbNewLine
Msg = "You have made changes to this record." & DL & _
"Are you SURE you want to save these changes?"
Style = vbQuestion + vbYesNo
Title = "ACCESS Database - Save Changed Data?"

If MsgBox(Msg, Style, Title) = vbNo Then
Cancel = True
Me.Undo
Else 'vbYes
DateLastModified = Now() 'will show date/time
UserLastUpdated = CurrentUser 'will show user who made a change
End If
End Sub

-------------- end ccode clip -----------

Thanks

FDBAdmin

Adam W
London, Canada
 
OK... Figured out the date update portion... Now I need to find out why my UserLastUpdate function is not working...

It was included in the string above, after I removed it (being the error causing the issue)...

Can I add a seperate function to update this? or does it have to be included in the same function?

FDBAdmin

Adam W
London, Canada
 
Thank you! Got it!

FDBAdmin

Adam W
London, Canada
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top