I am using Microsoft Office 365 --- Microsoft Access
I have included a simple database with one table and one form. [tbl Table] and [frm Table]
[tbl Table] has four fields .....[PrimaryKeyField], [Field 2], [Field 3] and [Result]
These four fields will be visible in [frm Table]. but [Result] will not be accessible to the user.
I wish to call a function in the Form_AfterUpdate
event that will use [Field 2] and [Field 3] and arguments. The result of the function will be stored in [Result]
All the code in the form is shown below
Option Compare Database
Private Sub Form_AfterUpdate()
[result] = CreateItemDescription([primarykeyfield])
Public Function CreateItemDescription(ByVal TheKey As String) As String
Dim rs_Record As DAO.Recordset
Set rs_Record = CurrentDb.OpenRecordset("Select * from [tbl Table] where [PrimaryKeyField] = '" & TheKey & "'")
CreateItemDescription = rs_Record![Field 2] & " : " & rs_Record![Field 3]
rs_Record.Close: Set rs_Record = Nothing:
This clearly does not work. When I try to change data in [Field 2] and / or [Field 3], the form won't let me get out of edit mode. I have some idea of the problem, but am unsure on how to solve the issue. I have included the database described here as an attachment.
I am sure that most of you wizards will know the solution in a snap. This is what makes this service so invaluable for me. Looking for great advice...... like usual.