Copying the value of a text box on another form.

the-m0th

Registered User.
Local time
Today, 14:23
Joined
Apr 14, 2015
Messages
51
Hi Everyone,

I'm trying to continue with my rebuild of our call answering screen. it's basically a form with a button for each company we represent, clicking the button will lead to a call answering screen for the company. we also have software that pops the correct screen when we receive a call for the corresponding company.

i'm trying to get some of the fields to autopopulate, starting with the telephone number of the caller. the number appears in a text box on the main form and i'm trying to copy it into the caller telephone box on the call answering form. i've got code in place but it gives me the error "you can't reference a property or method for a control unless the control has the focus". Just wondering if anyone can give me a few pointers to get it working? here's the code for the form i'm working on...

Code:
Option Compare Database

Private Sub cmd_recordcomplete_Click()
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.Close acForm, Me.Name
End Sub

Private Sub Form_Load()
    DoCmd.GoToRecord , , acNewRec
    txt_dateandtime.Value = Now
    Me.txt_callertelephone.Text = Forms!Switchboard!txt_incoming.Text
End Sub

Thanks
Wayne
 
sorted. in case anyone else is wondering, i changed .text to .value and all is good.
 
it is referring to the .text property

Me.txt_callertelephone.Text = Forms!Switchboard!txt_incoming.Text

both these controls cannot have the focus at the same time

note you do not need to use .value, this is implied and is the value of the control after update. .text is the value whilst the control is being changed
 
thanks for explaining, it's things like this that help people understand why instead of just knowing not to do something :)
 

Users who are viewing this thread

Back
Top Bottom