Forms newbie question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have been searching for the answer to this for several hours and it is is
probably just a 'forest for the trees' problem.

I have a form in which a textbox captures the Windows userID (control source
=fOSUserName) which works fine. How do I get this value into the underlying
table in a field called User ?

Sorry if this has already been addressed (which it no doubt has) but
sometimes it's the simple answers that are the hardest to find.

Thanks in advance,

IK
 
instead of putting the equation into the control

1. make the ControlSource the field you want to populate
2. use the form BeforeInsert event to fill to fill out the
control when a new record is being created

-------------------
me.controlname = fOSUserName()
-------------------

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
Hi Crystal,

Thanks for the prompt reply.

I'm OK with step 1.

It's step 2. that I have seen in my searches but I can't turn into reality.
For starters, superdumb question - what's with the "me." ? I ussume this is
supposed to be a generic filler and I am supposed to use a reference specific
to my database but which one ?

I have typed in the Before Update field on the Events tab for the text box -
frmQuote.Text20=fOSUserName(). frmQuote is the name of the form, Text20 is
the name of the textbox. I'm guessing I'm going wrong at about here. If I can
get this fundamental issue sorted, I'll be off and running.

TIA

IK
 
Hello,

Me. refers to the form (or report) that you are behind

BeforeInsert runs the moment a character is typed into a
field to create a new record

BeforeUpdate runs after BeforeInsert on a new record after
the fields are filled out AND it runs when you make changes
to a record. Once the record is created, I am assuming you
do not want to change this field again...but maybe you do...

you should always change the names of your controls to
something logical. Change the NAME property of Text20 to
reflect the contents of what is in there.

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
Crystal,

Thanks again for taking the time to reply.

Ok, got the Me. bit.

There is no Before Insert option available on the events tab for the text
box which is why I used the Before Update option. I don't imagine that I
would want the user name to change on a record at this stage.

So I now have "frmQuote.UserInfo=fOSUserName()" in the BeforeUpdate field
and I am not getting the username appearing in the table behind the form
(controlsource is set to the appropriate table field). What am I still doing
wrong ?

Regards,

IK
 
use the FORM BeforeInsert... sorry I didn't specify that...

you need to make the ControlSource property of your textbox
--> the field you are trying to fill

to turn on the property sheet:
fro the menu --> View, Properties

and then click on the textbox control and choose the Data
tab in the property sheet

to select the form, click in the upper left where the rulers
intersect and choose the Events tab on the property sheet

click in BeforeInsert and then on the Builder (...) button,
then Code Builder

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
inch by inch.....(thanks for your patience)

I now have the following in the code builder window -

Private Sub Form_BeforeInsert(Cancel As Integer)
frmQuote.UserInfo = fOSUserName()
End Sub

And I now get run-time error "424" - Object Required

OK....what have I screwed up now ?

IK
 
since you are in the code behind your form

Private Sub Form_BeforeInsert(Cancel As Integer)
Me.UserInfo = fOSUserName()
End Sub

besides, a valid reference would be
forms!frmQuote.UserInfo = fOSUserName()

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
you're welcome ;) happy to help

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
Back
Top