473,395 Members | 1,471 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Calling a function, basic question

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
5 1431
> 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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Satish Chimakurthi | last post by:
Hi all, My question is surely a basic one, but somehow, I am not able to figure it out. I have a python file "satish.py" as follows: *satish.py* def main(): y()
7
by: JCO | last post by:
I have several JavaScripts in a web page. Each script is in an individual file with extension .js. I want to know if it is possible to put all functions in one single page. If so, how do I call...
1
by: RA Scheltema | last post by:
hi all, I have the following function defined in the header-file of a c++ project struct DataType { ... };
3
by: scott | last post by:
hi all, hope some one can help me. Ill try and explain what im trying to do as best i can. i have a parent class that has a vertual function, lets call it virtual int A(). That vertual function...
4
by: Gibby Koldenhof | last post by:
Hiya, I'm setting up some code in the spirit of Design Patterns, OOP, etc. All nice and well, it handles pretty much all OO style things and serves my purposes well. There's one last final...
19
by: Ross A. Finlayson | last post by:
Hi, I hope you can help me understand the varargs facility. Say I am programming in ISO C including stdarg.h and I declare a function as so: void log_printf(const char* logfilename, const...
1
by: Nikhil | last post by:
Hi, I have defined a module called "Utility Functions" in MS-Access. In that module, I have defined a function called NullToZero. I used this function in one of my stored Queries in Access. This...
5
by: Stinky Pete | last post by:
Hi (again) ;-) I'm still very much at the bottom of a steep learning curve with VB, so any and all help is always appreciated. I've found some code to generate the user names who have logged...
9
by: Pubs | last post by:
Hi all, I want to call a function with some intial parameters with in a thread. At the end of the function execution it should return a value to the caller. Caller is outside the thread. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.