Avatar of developingprogrammer
developingprogrammer asked on

use UDF in table field's default value

hey guys,

i've got a table and one of the fields is staffID.

i've got a UDF called WindowsUserName which gets the username from windows api. (NOT the lousy environ function - only noobs do that) hahahaha

i've got a table that matches staffID with windows username.

in my default value for this staffID field, i want the.... ta da! staffID!

so i'm thinking 2 ways i can do it

1) WindowsUserName_To_StaffID(WindowsUserName)
2) Dlookup( blah blaah blah where username = WindowsUserName)

i just can't seem to figure out how to use functions in default values.

i tried =WindowsUserName but it gave me ="WindowsUserName"

tried Eval("WindowsUserName") and =Eval("WindowsUserName") but to no avail = (

hrmm i'm not sure how to do it. could yall help me guys?

thanks so sooo much!! = ))
Microsoft Access

Avatar of undefined
Last Comment
developingprogrammer

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP 2010-2015

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
developingprogrammer

whao guys, those are REALLY comprehensive answers to help me understand this issue!! thanks!!

on the side note as well, yall have introduced me to Before Insert event and that is so helpful! i use it to simulate the function where the user sees a form that doesn't allow additions, then they can click an "Add Row" button where the allowadditions become true thus showing an empty row, and when they start typing, i use the before insert event to enter some information into an invisible bound control so that record is not a new record anymore and then set allowadditions to false.

i'm sure i can think of more things in the future how to use this! thanks so much once again guys!! = ))
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck