Results 1 to 10 of 10
  1. #1
    desireemm1 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2009
    Posts
    50

    Combo Box

    Hello I have a Lookup Table that updates a child table through on combo called MERCodes. What happens is the user picks a code such as 7ca or 3ca and it populates 2 two to three fields depending on which the code. I need to add two more colums to the lookup table so that it will update two more fields, the problems I get an error message in my VBA code. Can anyone tell me what I am doing wrong please. I have to add the [StateCategory] and the [StateServicesCovered] also. Both tables have the same fields only one is used to update the other, by doing this it makes it easier and faster for the users to do data entry



    Error Message: "compiler error - method or data member not found".




    this is my original code:

    Code:
    Private Sub MERCodes_AfterUpdate()
    Me.Catagory_for_hours = Me.MERCodes.Column(2)
    Me.Catagory_for_hours.SetFocus
    Me.Catagory_for_hours.Dropdown
    Me.Services_Covered = Me.MERCodes.Column(3)
    Me.Services_Covered.SetFocus
    Me.Services_Covered.Dropdown
    Me.NameofWorkshop = Me.MERCodes.Column(4)
    Me.NameofWorkshop.SetFocus
    Me.NameofWorkshop.Dropdown
    Me.MERCodes.SetFocus
    
    
    
    End Sub
    Here is the code I added but its giving me an error

    Code:
    Private Sub MERCodes_AfterUpdate()
    Me.Catagory_for_hours = Me.MERCodes.Column(2)
    Me.Catagory_for_hours.SetFocus
    Me.Catagory_for_hours.Dropdown
    Me.Services_Covered = Me.MERCodes.Column(3)
    Me.Services_Covered.SetFocus
    Me.Services_Covered.Dropdown
    Me.NameofWorkshop = Me.MERCodes.Column(4)
    Me.NameofWorkshop.SetFocus
    Me.NameofWorkshop.Dropdown
    Me.StateCategory = Me.MERCodes.Column(5)
    Me.StateCategory.SetFocus
    Me.StateCategory.Dropdown
    Me.StateServicesCovered = Me.MERCodes.Column(6)
    Me.StateServicesCovered.SetFocus
    Me.StateServicesCovered.Dropdown
    Me.MERCodes.SetFocus
    
    
    
    
    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    What is the error message?

    Why are you saving this data? Is the selected code a PK key that all this data is associated with? Why not just save the code?

    Why are you doing the SetFocus and Dropdown methods?
    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.

  3. #3
    desireemm1 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2009
    Posts
    50
    Hello I was wondering what you meant by saving Data?? also here is the Error message

    "compiler error - method or data member not found".

  4. #4
    desireemm1 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2009
    Posts
    50
    This is the original code I used and it worked great

    [CODE]Private Sub MERCodes_AfterUpdate()
    Me.Catagory_for_hours = Me.MERCodes.Column(2)
    Me.Catagory_for_hours.SetFocus
    Me.Catagory_for_hours.Dropdown
    Me.Services_Covered = Me.MERCodes.Column(3)
    Me.Services_Covered.SetFocus
    Me.Services_Covered.Dropdown
    Me.NameofWorkshop = Me.MERCodes.Column(4)
    Me.NameofWorkshop.SetFocus
    Me.NameofWorkshop.Dropdown
    Me.MERCodes.SetFocus

    End Sub

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Why are you saving values from each column of combobox? This appears to be duplication of data when all that should be saved is primary key. Why the SetFocus and Dropdown actions?
    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.

  6. #6
    desireemm1 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2009
    Posts
    50
    Quote Originally Posted by June7 View Post
    Why are you saving values from each column of combobox? This appears to be duplication of data when all that should be saved is primary key. Why the SetFocus and Dropdown actions?
    There is a select statment in the properties of the combo boxes that leads to a lookup table the updates the child table which has a one to many relationship with the parent table. Not sure If i'm answering your question. The selections in the combo boxes come from a lookup table

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    No, did not ask about the RowSource select statement.

    Asking why you are saving each value that is in the row to a record? I.e., why setting Me.Catagory_for_hours = Me.MERCodes.Column(2)? Why doing any of these saves? This looks like duplicating the combobox box row to a record in another table.

    Also, don't understand why the SetFocus and Dropdown lines.
    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.

  8. #8
    desireemm1 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2009
    Posts
    50
    Quote Originally Posted by June7 View Post
    No, did not ask about the RowSource select statement.

    Asking why you are saving each value that is in the row to a record? I.e., why setting Me.Catagory_for_hours = Me.MERCodes.Column(2)? Why doing any of these saves? This looks like duplicating the combobox box row to a record in another table.

    Also, don't understand why the SetFocus and Dropdown lines.
    I asked on a forum like this one how to cascade combo boxes and they gave me that code its been working great ever since. I dont know really know to program in VBA just learning. If you have a better suggestion I'm open to it

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    What I see in your code is not cascading comboboxes. It is saving combobox data to fields of a record. If that is what you want then fine, but the SetFocus and Dropdown lines don't make sense for what you are doing.

    Review tutorials at http://datapigtechnologies.com/AccessMain.htm especially the 3 on comboboxes in the Access Forms: Control Basics section.
    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.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    The error "compiler error - method or data member not found" means Access/VBA can't find the referenced item. Something is probably misspelled.
    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. Replies: 33
    Last Post: 01-13-2012, 07:44 AM
  2. Replies: 4
    Last Post: 08-16-2011, 05:54 PM
  3. Replies: 5
    Last Post: 01-02-2011, 10:09 AM
  4. Replies: 1
    Last Post: 08-26-2009, 10:45 AM
  5. Replies: 0
    Last Post: 08-17-2008, 12:19 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