Storing info from one field into another.

G

Guest

I am trying to store the User Name received from the system into a table so
users can see who entered the record when they view the record in inquiry
mode and/or in the report.


Code:
Private Sub acct_num_Exit(Cancel As Integer)
If Me!UserName Is Not Null Then
Me!entered_by = Me!UserName
End If
End Sub

When the code runs I receive the following error:
Run-time error'424' Object required


I a using the [=fOSUserName()] to retrieve the user name from the system.

Thanks in advance for any suggestions.
 
W

Wayne Morgan

Try:

If Not IsNull(Me!UserName) Then

The syntax you are using is for a SQL query. This uses the VBA function
instead. I'm assuming that UserName is a calculated textbox whose control
source is =fOSUserName().
 
G

Guest

Hi, blueflame.

Although your intention is quite clear to those of us who read English, the
computer needs a more cryptic syntax. You need to call the IsNull function
with a Not operator.

Private Sub acct_num_Exit(Cancel As Integer)
If Not IsNull(Me!UserName) Then
Me!entered_by = Me!UserName
End If
End Sub

Hope that helps.
Sprinks
 
G

Guest

Sprinks and Wayne,

Much thanks!!

This works great.

Wayne Morgan said:
Try:

If Not IsNull(Me!UserName) Then

The syntax you are using is for a SQL query. This uses the VBA function
instead. I'm assuming that UserName is a calculated textbox whose control
source is =fOSUserName().

--
Wayne Morgan
MS Access MVP


blueflame said:
I am trying to store the User Name received from the system into a table so
users can see who entered the record when they view the record in inquiry
mode and/or in the report.


Code:
Private Sub acct_num_Exit(Cancel As Integer)
If Me!UserName Is Not Null Then
Me!entered_by = Me!UserName
End If
End Sub

When the code runs I receive the following error:
Run-time error'424' Object required


I a using the [=fOSUserName()] to retrieve the user name from the system.

Thanks in advance for any suggestions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top