Consulting

Results 1 to 5 of 5

Thread: COMBOBOX Value Recall

  1. #1

    COMBOBOX Value Recall

    I am a newbie on Excel VBA programming, please bear with me.
    I tried to look at the forum but I cannot find the right answer to my problem.

    My problem is i cannot recall the combobox value stored on Sheet1, when i click the edit button to recall all the data inputed on every textbox.
    Data inputed on the textboxes were saved on a specific sheet (Sheet1). There are only 2 choice/values on the combobox.
    If Sheet1.Range("D8").Value is 1.17 there is no problem.
    If Sheet1.Range("D8").Value is 0.8 then it returns an error, Run-time error 380 "Could not set the Value property. Invalid property value.

    MoldCapThickness.Clear
    With MoldCapThickness
    .AddItem "1.17"
    .AddItem "0.80"
    End With

    Private Sub Edit1_Click()


    SolderBallPitch.Value = Sheet1.Range("D4").Value
    MaxWireLength.Value = Sheet1.Range("D7").Value
    'MoldCapThickness is a combobox
    MoldCapThickness = Sheet1.Range("D8").Value


    End Sub

    Thanks for the help

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Although this is an Excel problem on an Access Forum, do you get the error message when the code running is
    .AddItem "0.80"
    or
    MoldCapThickness = Sheet1.Range("D8").Value

  3. #3
    Thank you for the reply, and apology for the wrong post on the Access forum.

    I was able to find an answer to my problem, but actually i dont fully understand the solution.
    The error occured on "MoldCapThickness = Sheet1.Range("D8").Value". with Run-time error 380 "Could not set the Value property. Invalid property value.

    One of the solution for this error is to declare a variable that can accept numbers and string, so that the value will be accepted.
    I tried to declare a variable with variant data type. And then my problem was solved.
    I tried other data type and only variant was working and i dont understand why double or long is not working.

    Below are the working codes.

    Dim iMCT As Variant

    iMCT = Sheet1.Range("D8").Value
    MoldCapThickness.Value = iMCT

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    The "Variant" type is basically a holding variable that will accept whatever is entered and is decided on the actual entry.
    Whereas Double and Long are both "Numeric" only variables.
    You could try a String variable as that also basicaly accepts any input.
    That was why I asked the question, you may be trying to assign a string value, ie used inverted commas rather than a numeric value, however that usually provokes a Type Mismatch error.
    I am glad you have got it working.

  5. #5
    Thank you for the time and for the explanation.

Posting Permissions

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