Solved

Populating ComboBox and refreshing subform from VB

Posted on 2013-06-12
3
398 Views
Last Modified: 2013-06-13
Dear experts

I am really struggling with an issue which I am sure someone can fix for me.

I have prepared a simplified database (attached) that should show the problem.

The database as it is at the moment has 2 objects (Groups and Contacts)
A group can have a contact assigned, but only those that are designated as valid for that group.

When creating or editing a group, the contact is selected from a ComboBox.  In the case of a new Group, the ComboBox would of course be empty.  So there is a “New Contact” button that allows to add a new contact for the group.  In the case of editing a Group, there is also a requirement to add a new contact, so the New Contact button is also required there.

I am not using the ComboBox option “List Items Edit Form”, because this application needs to work under Access  2003 as well.

My problem is that, when the frmAddMainContactToList closes (using the Save button) the comboBox on the main form is not populated with the new ContactID and the subform showing the contact details is not refreshed.
I hope this is a clear enough explanation.

Regards

Richard
Simplified-database---EE-120613.mdb
0
Comment
Question by:rltomalin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39241226
Firs things first: If the app must work with 2003, then you would be STRONGLY advised to actually develop it in 2003. From your earlier question I assume that you're using a later version, like 2007 or 2010. There can be (and normally are) issues with non-trivial applications developed in 2001/2010 and then deployed to users with 2003.

If I recall, you goal in this matter is to be able to add a New Contact to an existing Group, by the user selecting a value in the combo, or by clicking your "New Contact" button. Is that correct?

I believe your issue stems from the way you're using the Master and Child link fields for your subform. You've linked both GroupID and ContactID, and you shouldn't do that - since that limits your subform's Recordsource to a single record (assuming the combination of GroupID and ContactID represent a unique record, of course).

Instead, try linking on ONLY GroupID form both Master and Child links, and then using code in the main form's Current event to "set" the value in the MainContact subform:

Private Sub Form_Current()

    Dim rst    As DAO.Recordset
    Set rst = Me.MainContactDetails.Form.RecordsetClone

    rst.FindFirst "ContactID=" & Me.MainContactID

    If Not rst.NoMatch Then
        Me.MainContactDetails.Form.Bookmark = rst.Bookmark
    End If

End Sub

Open in new window


To manage the New Contact stuff, you'll need to make some changes in the way your popup form interacts with the "main" form. In essence, you'd do this:

1) Add a new property to frmAddMainContactToList to store the "current" contact.
2) Open your popup form as a Dialog form
3) In the popup form, "set" the property from Step1 when it closes
4) Now back in frmAddMainContactToList, use the value set in Step 3 to sync your combo and subform.

I've made some changes and reattached your sample.
Simplified-database---EE-120613.mdb
0
 

Author Comment

by:rltomalin
ID: 39241339
Thanks LSM
I will look at this tomorrow now.

Regards

Richard
0
 

Author Closing Comment

by:rltomalin
ID: 39243778
Hi LSM
Thank you - that seems to have fixed it.  I am having a bit of a problem figuring out exactly why it works because it is using code that I am not familiar with.  But I will work my way through and introduce the tecniques to me application and then hopefull it will work.

Regards
Richard
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question