Link to home
Start Free TrialLog in
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!! = ))
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of developingprogrammer
developingprogrammer

ASKER

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!! = ))