Changing a field content from VBA

Scott Heslop

Registered User.
Local time
Today, 22:02
Joined
Aug 29, 2012
Messages
17
Hi,

Ive recently changed my table from a *.MDB to a *.ACCDB and ive found an error which worked fine in *.MDB format but when i changed it over it gives me and error. Im wanting to change a field value from "Active" to "Archive" if i click on the archive button. Here is my code:

The red sections are where my code fails. Any suggestions?

Private Sub TransferButton_Click()
Dim cMsgTxt As String
Dim nAns As Integer
If cMode = "Active" Then

cMsgTxt = "Archive "
If Not IsNull(Me![cEmployeeForename]) Then
cMsgTxt = cMsgTxt & UCase(Me![cEmployeeForename])
End If

If Not IsNull(Me![cEmployeeForename]) Then
cMsgTxt = cMsgTxt & " " & UCase(Me![cEmployeeSurname])
End If

cMsgTxt = cMsgTxt & " ? Are you sure ?"
If MsgBox(cMsgTxt, vbYesNo) = vbNo Then
Exit Sub
End If

Me!cActiveOrArchived = "Archived"

Me.Requery

Else

cMsgTxt = "Reinstate "
If Not IsNull(Me![cEmployeeForename]) Then
cMsgTxt = cMsgTxt & UCase(Me![cEmployeeForename])
End If

If Not IsNull(Me![cEmployeeForename]) Then
cMsgTxt = cMsgTxt & " " & UCase(Me![cEmployeeSurname])
End If

cMsgTxt = cMsgTxt & " ? Are you sure ?"
If MsgBox(cMsgTxt, vbYesNo) = vbNo Then
Exit Sub
End If

Me!cActiveOrArchived = "Active"

Me.Requery

End If
End Sub
 
Try changing "!" to "."
Else post the error message.
 
JHB,

That didnt seem to work. It give me run-time error '2448'

Any Suggestions?
 
As
Else post the error message.
has mentioned, post the entier Error message..
Runtime Error : Error Number
Error Message
Something like..
attachment.php
 

Attachments

  • attachment.png
    attachment.png
    16.3 KB · Views: 205
Last edited:
[FONT=&quot]Exactly what I mean - error number can depend of the MS-Access version.


[/FONT]
 

Users who are viewing this thread

Back
Top Bottom