Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2006
    Posts
    3

    Exclamation Unanswered: Problem specifying Object variable

    Hi,

    I would appreciate any help on this case...

    I have a Form which has several Rectangle objects inside. On the same Form I have a subform with the names of the different Rectangles.
    I wish that whenever I select a record on the subform, the related Rectangle changes its background color.

    On the Master Form (FrmPackages) I have the following code:

    Option Compare Database
    Dim SkidName As Object


    Then on the subform (subFrmSkids) I have the following code:

    Private Sub Form_Click()
    Set SkidName = TagN° 'Field with name of the rectangle
    Forms![FrmPackages].Form.Text165.Value = SkidName
    Forms![FrmPackages].Form.SkidName.BackColor = 16755084
    End Sub


    When running the DB, as soon as I select a record on the subform (subFrmSkids) I get the following error:

    Run-time error '2465'
    Application-defined or Object-defined error


    Thanks in advance.

  2. #2
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    I think you are over complicating it (and confusing Objects with text variables!)

    I think something like this should do what you want

    Private Sub Form_Click()

    Set SkidName = Form_FrmPackages.Controls(TagNo)
    Form_FrmPackages.Text165=TagNo
    SkidName.BackColor = 16755084

    End Sub

    Assuming, as you implied, TagNo is a field holding the name of the rectangle control as a string.

    If you are using Acess97 then it perhaps shouod be likr this

    Private Sub Form_Click()

    Set SkidName = Form("FrmPackages").Controls(TagNo)
    Form("FrmPackages").Text165=TagNo
    SkidName.BackColor = 16755084

    End Sub

    The latter will work for any version as Access (I think!)

    HTH


    MTB

    ps as indicated before this is too complicate!
    This is a little silmpler

    Private Sub Form_Click()
    Form("FrmPackages").Text165=TagNo
    Forms("FrmPackages").Controls(TagNo).BackColor = 16755084
    End Sub
    Last edited by MikeTheBike; 10-27-06 at 04:42.

  3. #3
    Join Date
    Oct 2006
    Posts
    3
    Hey Mike!

    Thanks for your help! You are right, I am complicating things a little, but with your help I got it working perfect!

    I used the first option that you gave me (I'm using Access 2000). I had to specify an Object Variable due to all the other instruction lines that I have (I only posted the first ones).

    Thanks again,

    Ed

Posting Permissions

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