By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,327 Members | 1,805 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,327 IT Pros & Developers. It's quick & easy.

Calling a function, basic question

P: n/a
ARG! I've tried so hard to avoid posting this, but I just can't get
it to work!

I have a form used for data entry, has about 10 fields on it. I want
to collect the user's network login ID after they move to the next
record, and have the system put it in a field for that record called
[user_name].

I found Dev's code at http://www.mvps.org/access/api/api0008.htm

His code works fine in the module I created and named modUserName...
I actually made one change to Dev's code, that I think was sort of
redundant, but I added "Public" before "Function"...it's in a global
module though, so I think it was unnecessary.

SO, now my roadblock has become how to call that function in the code
on the after_update property of my form??

I've tried it so many different ways and it keeps telling me it can't
compile the module.

I know it's something as simple as me.user_name = fOSUserName... or
something like that, but I can't figure this out!!

As weird as this looks, this is my most recent attempt...

Private Sub Form_AfterUpdate(fOSUserName As String)
Dim strName As String
strName = fOSUserName
Set user_name = strName
End Sub

I know this is pretty basic, but I've been trying to find help on this
all morning, could someone PLEASE help me?? Thank you!!!!!!
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
> Private Sub Form_AfterUpdate(fOSUserName As String)
Dim strName As String
strName = fOSUserName
Set user_name = strName
End Sub
Changing the above it would be

Private Sub Form_AfterUpdate()
Dim strName As String
strName = fOSUserName 'this may need to be fOSUsername()
Me.user_name = strName
End Sub

Now, for what you are describing, is the AfterUpdate event what you're
after? Do you want this to be the default value of the field in a new
record, have this placed in the field for every record that is viewed
whether or not the record is changed, or what?

--
Wayne Morgan
Microsoft Access MVP
"Donna Sabol" <ds********@yahoo.com> wrote in message
news:e8**************************@posting.google.c om... ARG! I've tried so hard to avoid posting this, but I just can't get
it to work!

I have a form used for data entry, has about 10 fields on it. I want
to collect the user's network login ID after they move to the next
record, and have the system put it in a field for that record called
[user_name].

I found Dev's code at http://www.mvps.org/access/api/api0008.htm

His code works fine in the module I created and named modUserName...
I actually made one change to Dev's code, that I think was sort of
redundant, but I added "Public" before "Function"...it's in a global
module though, so I think it was unnecessary.

SO, now my roadblock has become how to call that function in the code
on the after_update property of my form??

I've tried it so many different ways and it keeps telling me it can't
compile the module.

I know it's something as simple as me.user_name = fOSUserName... or
something like that, but I can't figure this out!!

As weird as this looks, this is my most recent attempt...

Private Sub Form_AfterUpdate(fOSUserName As String)
Dim strName As String
strName = fOSUserName
Set user_name = strName
End Sub

I know this is pretty basic, but I've been trying to find help on this
all morning, could someone PLEASE help me?? Thank you!!!!!!

Nov 12 '05 #2

P: n/a
The AfterUpdate event does not have any arguments, and you should never add
any to one.
What is user_name? If it is a field on the form, then don't use the Set
statement. Only use this when assigning an object to a variable.

Remove the arguments.
Unless you are using the return value from the API, it's just a waste of
time to dim a variable and assign it, then assign it to a field.
Use Me!user_name = fOSUserName

Mike Storr
www.veraccess.com
"Donna Sabol" <ds********@yahoo.com> wrote in message
news:e8**************************@posting.google.c om...
ARG! I've tried so hard to avoid posting this, but I just can't get
it to work!

I have a form used for data entry, has about 10 fields on it. I want
to collect the user's network login ID after they move to the next
record, and have the system put it in a field for that record called
[user_name].

I found Dev's code at http://www.mvps.org/access/api/api0008.htm

His code works fine in the module I created and named modUserName...
I actually made one change to Dev's code, that I think was sort of
redundant, but I added "Public" before "Function"...it's in a global
module though, so I think it was unnecessary.

SO, now my roadblock has become how to call that function in the code
on the after_update property of my form??

I've tried it so many different ways and it keeps telling me it can't
compile the module.

I know it's something as simple as me.user_name = fOSUserName... or
something like that, but I can't figure this out!!

As weird as this looks, this is my most recent attempt...

Private Sub Form_AfterUpdate(fOSUserName As String)
Dim strName As String
strName = fOSUserName
Set user_name = strName
End Sub

I know this is pretty basic, but I've been trying to find help on this
all morning, could someone PLEASE help me?? Thank you!!!!!!

Nov 12 '05 #3

P: n/a
I chose AfterUpdate on the form because I wanted the system to capture
the name of the user when they are finished making changes to the
record. I don't know if they will fill in all fields, so I couldn't tie
it to just one field. "user_name" is a field in the table.

If AfterUpdate is not what I should use, what would be my best bet?

I actually tried strName = fOSUserName...it didn't work. But I just
posted on the newsgroup a few minutes ago that even the simpliest code
isn't working on this form. Other forms in my database have code that
works, so I'm thinking about recreating this form (yuck)

So, for now, where should I put the reference to the username on my
soon-to-be-recreated form?

Thanks!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #4

P: n/a
Are you sure the AfterUpdate for the form is even firing?

"Donna Sabol" <ds********@yahoo.com> wrote in message
news:40*********************@news.frii.net...
I chose AfterUpdate on the form because I wanted the system to capture
the name of the user when they are finished making changes to the
record. I don't know if they will fill in all fields, so I couldn't tie
it to just one field. "user_name" is a field in the table.


Nov 12 '05 #5

P: n/a
Donna Sabol wrote:
I chose AfterUpdate on the form because I wanted the system to capture
the name of the user when they are finished making changes to the
record. I don't know if they will fill in all fields, so I couldn't tie
it to just one field. "user_name" is a field in the table.

If AfterUpdate is not what I should use, what would be my best bet?

I actually tried strName = fOSUserName...it didn't work. But I just
posted on the newsgroup a few minutes ago that even the simpliest code
isn't working on this form. Other forms in my database have code that
works, so I'm thinking about recreating this form (yuck)
Nonono, don't recreate the form. You must get your project to compile
before events can be used. Get rid of that error.

And, this:
Private Sub Form_AfterUpdate(fOSUserName As String)
Dim strName As String
strName = fOSUserName
Set user_name = strName
End Sub
should be:

Private Sub Form_AfterUpdate()
Dim strName As String
strName = fOSUserName
user_name = strName
End Sub

(I indented to visibly separate executing statements from declarations)

Or, shorter:

Private Sub Form_AfterUpdate()
me!user_name = fOSUserName()
End Sub

So, for now, where should I put the reference to the username on my
soon-to-be-recreated form?

Thanks!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.