Results 1 to 14 of 14
  1. #1
    reidn is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jun 2011
    Posts
    37

    Problemss filling textboxes from combobox

    Hey, I am new to access and have a quick question.

    I created a combobox that draws data (Workorder, Quantity, Country of origin, Customer) from a table with this info. When I select the workorder I want the other textboxes that I have to autofill with the other information from that certain workorder (quantity, COO, and customer).

    I have the following code written to do this:

    Private Sub Combo98_AfterUpdate()

    OQT.SetFocus
    Me!OQT.Text = Me!Combo98.Column(1)
    JCO.SetFocus
    Me!JCO.Text = Me!Combo98.Column(2)
    CN.SetFocus


    Me!CN.Text = Me!Combo98.Column(3)

    End Sub

    I added the set focus because when I first atempted to run it an error message popped up stating that the specified field could not be edited without focus. After that change was made I ran it again and this time an error message popped up saying that the field could not be changed because it is read only.

    Please help me out with this
    Thanks

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Don't use .TEXT You don't need to use that in 99% of the places. Use the .Value property instead as it does NOT require the control to have the focus. So, you would use:

    Code:
    Private Sub Combo98_AfterUpdate()
    
    Me!OQT = Me!Combo98.Column(1)
    Me!JCO = Me!Combo98.Column(2)
    Me!CN = Me!Combo98.Column(3)
    
    End Sub
    As far as the read only part - you need to make sure that the record source for your form is updatable. What are you using for your form's record source? Is it a query? If so, what is the SQL for it?

  3. #3
    reidn is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jun 2011
    Posts
    37
    Thank you for responding,

    How can I check? I am pretty sure It is a table and is is a different table from the one that the combobox references

  4. #4
    reidn is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jun 2011
    Posts
    37
    I ran it again and a similar message, cannot assign a value to this object, came up

  5. #5
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    You would check by opening the form in design view and then checking the RecordSource property to see if it is a name of a table, a name of a query, or a SQL Statement.

    Second, the fields of OQT, JCO, and CN must be fields in that record source, whatever it is in order for this to work.

  6. #6
    reidn is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jun 2011
    Posts
    37
    The record source is a separate table without the fields. How could I do it then?

  7. #7
    reidn is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jun 2011
    Posts
    37
    And I'm sorry if this seems like a silly question. I have just been playing with this and forum surfing all day and cant find an answer...

  8. #8
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by reidn View Post
    The record source is a separate table without the fields. How could I do it then?
    Well, my question is then where ARE they located?

    Instruction Point #1:

    When you refer to ME it means the current class object, and in this case the form. So, if you say Me!JCO then you are referring to a field within the record source of the form. If that field doesn't exist then you can't do that.

    So, you would either need to use a query as the form's record source with that table also in the query as well as the other fields from the first table that is currently in the form's record source, or you might need to use a subform in order to do that. It really depends on your table structure and, since I can't see it, I can't give you real specifics on how to handle it.

  9. #9
    reidn is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jun 2011
    Posts
    37
    [IMG]file:///C:/DOCUME%7E1/NER1AT/LOCALS%7E1/Temp/moz-screenshot.png[/IMG]How could I do it by creating a subform?

  10. #10
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by reidn View Post
    [IMG]file:///C:/DOCUME%7E1/NER1AT/LOCALS%7E1/Temp/moz-screenshot.png[/IMG]How could I do it by creating a subform?
    you can't put an image up by referring to a picture on your computer. You need to UPLOAD it. When doing a reply click on GO ADVANCED and then click MANAGE ATTACHMENTS, browse to the file, click UPLOAD and then if a link appears under the text box which had the file name when you clicked upload then it uploaded. Then you can use the image tags to display that URL.

  11. #11
    reidn is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jun 2011
    Posts
    37
    here it is

  12. #12
    reidn is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jun 2011
    Posts
    37
    here it is Form.jpg.jpg

  13. #13
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    See the text boxes that say #Name in them? That means that you have it bound to something that it has no clue about.

    I'm about out of time today but you probably would be good to upload a copy of your database (with bogus data of course) so then we can have a better clue as to what is going to be needed. Hopefully someone else might step in while I'm gone to help. Otherwise it will be at least 18 hours before I'll be even close to being able to look again.

  14. #14
    reidn is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jun 2011
    Posts
    37
    I will make sure to do that. Thank you for all of your help Bob

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Problem filling textboxes from combobox
    By reidn in forum Forms
    Replies: 1
    Last Post: 06-23-2011, 05:06 PM
  2. Filling a combobox with field names.
    By millerdav99 in forum Access
    Replies: 1
    Last Post: 04-26-2011, 02:09 PM
  3. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  4. Replies: 0
    Last Post: 12-16-2009, 01:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums