Results 1 to 8 of 8
  1. #1
    Join Date
    May 2007
    Posts
    31

    Unanswered: Change value/Control source of text box on form

    I have a form that I would like if the user clicks the value on the form an input box appears to accept a new value.

    When I try to write it back to the form I get error 2448 - object required.

    Private Sub txtCYRQtr2_Click()
    Dim q1 As String

    q1 = InputBox("Enter total sales per quarter")
    Me!txtCYRQtr2 = Val([q1]) **this is the line that blows.



    End Sub

    Thanks for your help.

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Just do away with Val. You only need Me!txtCYRQtr2 = q1
    q1 is a variable, not an object, but your code was treating it as an object.
    Inspiration Through Fermentation

  3. #3
    Join Date
    May 2007
    Posts
    31
    Still no go....

    I miss stated the error message - it's "You can't assign value to this object."

    I don't want the user to have to go into the form design to change this value.

    Any other suggestions??

    Thanks

  4. #4
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    I missed something there. You're using a control's on click event to ask the user for the value to put into the control???? Why not just let the user directly update the control?
    Inspiration Through Fermentation

  5. #5
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    what part of the object you talking to

    Me!txtCYRQtr2 = Val([q1])

    you are telling put q1 into Me!txtCYRQtr2 but where

    try

    Me!txtCYRQtr2.text = Val([q1])
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  6. #6
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    From Access Help for VAL function
    Returns the numbers contained in a string as a numeric value of appropriate type.

    The following returns the value 1615198:

    Val(" 1615 198th Street N.E.")
    Is that really what you're trying to do?
    Even if you are, don't enclose q1 in [].
    Inspiration Through Fermentation

  7. #7
    Join Date
    May 2007
    Posts
    31
    I tried that but it didn't work either.

    Since this morning though I've devised a way for a "hidden" form to populate the feild so there is no longer any need to have the user change.

    It's probably better this way - no chance of fat fingered folks to mess things up:0)

    Thanks for you help though!

  8. #8
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    I don't want the user to have to go into the form design to change this value.
    Why do you think the user would have to go into Design View to change the value? In point of fact, you can't change the value of a textbox in Design View!

    As RedNeckGeek said
    You're using a control's on click event to ask the user for the value to put into the control???? Why not just let the user directly update the control?
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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