Results 1 to 10 of 10
  1. #1
    keiath is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    162

    Saving look up information

    Hi Guys



    Hope someone can help

    I have a combo (Exp Code) that looks up in a form from another table, which saves in the current form table, in a txt box it the auto fills the description:-

    Private Sub Expense_Code1_Change()
    Private Sub Combo163_AfterUpdate()
    Me.Text169 = Me.Combo163.Column(1)
    End Sub

    this works fine, but how to i get it to save in the form table because when ever i return to the form the information has disappeared.

    Any ideas?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    In your VBA editor have you tried compiling the code? From the tool bar, Debug > Compile

  3. #3
    keiath is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    162
    its working fine just not saving in the current form so i think i am missing some code

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Why are you saving the descriptive value? If you are saving the ID then should not save descriptor.

    As already suggested, run Debug > Compile. It will reveal that your code structure is bad. You have two Sub declaration lines when there should be only one.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    keiath is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    162
    Quote Originally Posted by June7 View Post
    Why are you saving the descriptive value? If you are saving the ID then should not save descriptor.

    As already suggested, run Debug > Compile. It will reveal that your code structure is bad. You have two Sub declaration lines when there should be only one.


    Private Sub Combo163_AfterUpdate() Me.Text169 = Me.Combo163.Column(1)End Sub
    this is now corrected, but it at the moment its saving the description field on every form, whereas the exp code (the combo from which the auto-fill gets its information) because its saved only shows on that record

    Hope that all makes sense now

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Do not understand last post.

    Also, you did not answer question about why saving descriptor.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    keiath is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    162
    Private Sub Combo163_AfterUpdate()
    Me.Text169 = Me.Combo163.Column(1)End Sub

    the code is corrected.

    when i select code '55' it displays
    All Grounds Maintenance, but it displays 'All Grounds Maintenance' on every record, if I go to another record and select '63' 'Cleaning General' then shows on every record including the previous record that has code '55' now says 'Cleaning General'

    where one record should say '55' All Grounds Maintenance and the next record '63' 'Cleaning General' what am i doing wrong~?

    Thanks for taking time to look at this problem

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Because Text169 is not bound to a field of the form RecordSource. Unbound controls and controls without dynamic expression will display same value for all records.

    Only use code to populate data control if you want to save value into a field of record. The data control must also be bound to the field.

    If you only want to display the descriptor then use expression in the textbox ControlSource:
    =[Combo163].[Column](1)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    keiath is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    162
    Quote Originally Posted by June7 View Post
    Because Text169 is not bound to a field of the form RecordSource. Unbound controls and controls without dynamic expression will display same value for all records.

    Only use code to populate data control if you want to save value into a field of record. The data control must also be bound to the field.

    If you only want to display the descriptor then use expression in the textbox ControlSource:
    =[Combo163].[Column](1)

    THANK YOU

    I don't know why i didn't see that! Duh!

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Again, saving the descriptor value is unnecessary and against basic relational database principles.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Saving a macro
    By kdbailey in forum Access
    Replies: 11
    Last Post: 03-19-2013, 08:05 AM
  2. Form Combo Box Saving Wrong Information
    By Steve62 in forum Reports
    Replies: 5
    Last Post: 11-12-2012, 02:29 PM
  3. saving a form
    By Ray67 in forum Forms
    Replies: 11
    Last Post: 10-23-2011, 06:45 PM
  4. Saving over a query
    By dssrun in forum Programming
    Replies: 2
    Last Post: 03-21-2011, 08:26 AM
  5. Saving Record
    By mwabbe in forum Programming
    Replies: 12
    Last Post: 09-15-2010, 12:09 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