Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003

    Question Unanswered: object required: setting the value for a public variable

    My subform contains a fileld and a update button:
    field name: txtcurrent_exch_rate1

    When clicking on the button, the value in the text field is saved to the underlying table and I want the following to happen:
    A public variable should be updated, as well as the value of an unbound text field on the parent form. (field name: txtCurrentExchRate2)

    I have the following code:

    On the declarations section of the main form (parent form):
    Public gcurrExchRate As Currency

    On the subform:
    Private Sub cmdUpdateExchRate_Click()
    On Error GoTo Err_cmdUpdateExchRate_Click

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

    gcurrExchRate = Me.txtcurrent_exch_rate1.Value
    Set Me.Parent.txtCurrentExchRate2.Value = Me.txtcurrent_exch_rate1.Value

    I get an error message about object required. The debug option then marks the variable (gcurrExchRate) in the following line:
    gcurrExchRate = Me.txtcurrent_exch_rate1.Value

    What am I doing wrong? There are some parts of the logic & use of objects, variables and functions that I have not understood properly.


  2. #2
    Join Date
    Nov 2002
    Try this:

    gcurrExchRate = Me.txtcurrent_exch_rate1

  3. #3
    Join Date
    Jan 2004

    Re: object required: setting the value for a public variable

    Originally posted by kedaniel

    Set Me.Parent.txtCurrentExchRate2.Value = Me.txtcurrent_exch_rate1.Value

    KenneyG is right, but didn't provide an explanation.

    The Set keyword is only for setting an object reference, not for setting values. Also, Since Value is the default property of all of Access' bindable controls, you don't need to explicitly call the Value Property. Thus "MyTextBox.Value" and "MyTextBox" have the same result.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts