Referencing form element in BeforeUpdate procedure

bwgreen

Registered User.
Local time
Yesterday, 21:52
Joined
May 28, 2014
Messages
20
Hi,

I have an issue with a BeforeUpdate procedure that I am trying to get working. I'm using simple elements here as this is a test DB, not the real one yet.

I'm trying to get the value from a Text Box TextData into a string cString. I've used a Dim statement to declare cString - I think the problem I am having is trying to get the actual data from the form. The error I am getting is:

Run Time error '2465'

Microsoft Access cannot find the field "|1" referred to in your expression.

The code I am using is:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim cString As String

cString = [Forms!FormData!TextData]

End Sub

(I've removed some code that is either comments or working since I have to retype things!)

The line cString = [Forms!FormData!TextData] is where the debugger highlights as the error.

Any ideas?
 
Simply use,
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim cString As String
    cString = Me.TextData
End Sub
 
That works great - thanks! And thanks for the fast reply!
 

Users who are viewing this thread

Back
Top Bottom