No prob. Here are the steps:
1 - Create a new standard code module and paste the code on this page
http://www.mvps.org/access/api/api0008.htm into it. (Menu: Insert > Module)
Name the module basApiFunctions. (Whatever you do, don't name the module the
same as any of the procedures in your app.) Compile the code.
2 - Create a new query based on the table. (Menu: Insert > Query)
3 - Create a new form based on the query. (Menu: Insert > Form) You base
the form on the query instead of the underlying table so you have flexibility
to add other tables, sort and filter the data in the query.
4 - Access will name the text box bound to the reps field the same name.
While the form is in design view, change that text box's name to txtReps in
the form's properties.
5 - Go to the events tab in the form's properties. Scroll down till you see
OnOpen. Click on the combo box next to it and choose [Event Procedure].
Click on the three dots to the right of the combo box to open the code module
in the open event. Add the code I suggested in my earlier post and error
handling. Your Form_Open procedure should look a lot like this:
'start of code:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Proc_Err
Me.txtReps = fOSUserName()
Proc_Exit:
Exit Sub
Proc_Err:
MsgBox Err.Number & vbcrlf & Err.Description
Err.Clear
Resume Proc_Exit
End Sub
'end of code
Compile the code and save the form. When the form opens, your windows user
name will show in the text box and be saved in the table.
Chris
Microsoft MVP
thanks for the help, but im kinda new to this so can you explain how to do
this. thanks