Update a Field form another

  • Thread starter Thread starter PR
  • Start date Start date
P

PR

I am trying to get a field update from another if the first field is null
(Blank)... I am trying to do this with the after update event...

Private Sub Surname_AfterUpdate()
Me.PK_MembershipNo = Me.PK_ID

Dim RegNo As String
If Me.RegtNo Is Null Then
Me.RegNo = Me.PK_MembershipNo
End If
End Sub

Can anyone let me know why this does not work...
 
Just a syntax problem. You are trying to code it like SQL to check for Null.
You need to use the IsNull function. Also, as a matter of form, it is
better to do all your dims at the top of a procedure. It is easier to find
them and you don't run the risk of code mods that bypass them when they are
needed:

Private Sub Surname_AfterUpdate()
Dim RegNo As String

Me.PK_MembershipNo = Me.PK_ID
If IsNull(Me.RegtNo) Then
Me.RegNo = Me.PK_MembershipNo
End If
End Sub
 
Thank you for the solution...

Paul


Klatuu said:
Just a syntax problem. You are trying to code it like SQL to check for
Null.
You need to use the IsNull function. Also, as a matter of form, it is
better to do all your dims at the top of a procedure. It is easier to
find
them and you don't run the risk of code mods that bypass them when they
are
needed:

Private Sub Surname_AfterUpdate()
Dim RegNo As String

Me.PK_MembershipNo = Me.PK_ID
If IsNull(Me.RegtNo) Then
Me.RegNo = Me.PK_MembershipNo
End If
End Sub
 
Back
Top