Results 1 to 11 of 11
  1. #1
    Join Date
    Sep 2005
    Posts
    240

    Unanswered: Can't assign value to textbox

    Hey,

    I keep getting an error when trying to assign a value to a textbox.

    Run-time error '2448':

    Can't assign value to object.
    I've never had this before. Basically the textbox is on another form, and I need the ID from the OpenArgs function to populate the textbox so I can add the record. This is my code:

    Code:
    Me!Emp_ID = Mid(Me.OpenArgs, InStr(Me.OpenArgs, ".") + 1)
    You may be wondering why I'm doing it this way, and that's because more than one form is able to access it, so in the OpenArgs is the [name of the form] + . + [ID Number].

    The only properties for the textbox that are assigned are the control source and the visible property set to No, everything else is default.

    Can anyone help?

    Thanks.

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    WHERE are you trying to do this assignment at? Form Open? Form Load?

    Did you try: Emp_ID.Value= ...
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Sep 2005
    Posts
    240
    It's on Form_Load.

    I thought the exclamation mark was instead of having to use .Value everytime, but yes I did try .Value, and also .DefaultValue but it still didn't work.

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by KevCB226
    It's on Form_Load.

    I thought the exclamation mark was instead of having to use .Value everytime, but yes I did try .Value, and also .DefaultValue but it still didn't work.
    The ! in used in place of .Text ... You're problem is that OpenArgs I believe is available during Form Open ... At least, that is the only place that I've used it ...
    Back to Access ... ADO is not the way to go for speed ...

  5. #5
    Join Date
    Sep 2005
    Posts
    240
    Quote Originally Posted by M Owen
    The ! in used in place of .Text
    Well...It's almost the same thing.

    Just tried it on Form Open, and it doesn't like being placed in there either.

  6. #6
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by KevCB226
    Well...It's almost the same thing.

    Just tried it on Form Open, and it doesn't like being placed in there either.
    Okay ... Well try this: Plop your OpenArgs into a local string variable and operate on it from there ... Also, what version of Access is this?
    Back to Access ... ADO is not the way to go for speed ...

  7. #7
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Basically the textbox is on another form, and I need the ID from the OpenArgs function to populate the textbox so I can add the record. This is my code:
    [Code]Me!Emp_ID = Mid(Me.OpenArgs, InStr(Me.OpenArgs, ".") + 1)
    Hope this helps!

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

    All posts/responses based on Access 2003/2007

  8. #8
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by Missinglinq
    [Code]Me!Emp_ID = Mid(Me.OpenArgs, InStr(Me.OpenArgs, ".") + 1)
    Um ... What did you change??? Loks identical to Kev's ...
    Back to Access ... ADO is not the way to go for speed ...

  9. #9
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Sorry! That got sent accidentally! I was noodling around trying to figure it out and hit the wrong key!
    Hope this helps!

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

    All posts/responses based on Access 2003/2007

  10. #10
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Am I correct that you're trying to pass the Emp_ID from, say, Form A to Form B and fill out textbox on Form B? If so, why not go M Owen's suggestion one further and assign it to a global variable and skip the OpenArgs completely?
    Hope this helps!

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

    All posts/responses based on Access 2003/2007

  11. #11
    Join Date
    Sep 2005
    Posts
    240
    Thanks guys, I managed to get it working after spending an hour running through the code and related tables.

    It seems that Access was being arsey with me because I hadn't specified the ID as a Primary Key in the table, which usually helps

Posting Permissions

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