Solved

Trying to add a combo and list box that pulls from seperate tables and updates a table

Posted on 2013-01-07
20
255 Views
Last Modified: 2013-01-09
Table 1 - Employee Data
Table 2 - Skills Data
Table 3 - Resources

Objective is:
Step 1: Pull employee information from Table 1 by Employee ID #.  This Combo box will auto populate my form while updating Table 3 on the back end.  >> This works with simple code (see below)

------------------------------------------------------------------------------------------
Code that populates Table 3 for Step 1:
Private Sub cboLogin_Change()

Me.txtFirst.Value = Me.cboLogin.Column(1)
Me.txtLast.Value = Me.cboLogin.Column(2)
Me.txtFull_Name.Value = Me.cboLogin.Column(3)
Me.txtEmail.Value = Me.cboLogin.Column(4)

End Sub
----------------------------------------------------------------------------

Step 2:  Skills section pulls from Table 2, must be able to multi-select data (Access, SQL, VB) and update table 3 in the skills field.

I can create a combo box with multi-select capabilites, but this does not update Table 3.  The skills field is set to text.

What am I missing?
0
Comment
Question by:gracie1972
  • 10
  • 5
  • 4
  • +1
20 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
you can achieve this using multi valued field in Table3, but i would recommend to create another table "tblEmpSkills" with Employee ID , and Skills ID fields

so, your table relations between Resources and tblSkills will be 1 to many on the Employee ID field

Resources                            tblEmpSkills
EmployeeID   1 --- > M  EmployeeID
                                      SkillID
0
 
LVL 13

Expert Comment

by:MrBullwinkle
Comment Utility
If you put a line break in on your first line of cboLogin_Change, are the proper values displayed when you mouse over Me.cboLogin.Column(1)?

As for Step 2, are you asking for a list of selectable skills to be populated from Table2, and assigned to the selected person from CBOLogin?  If this is so, are you able to get the populating to work, just not the save?
0
 

Author Comment

by:gracie1972
Comment Utility
@MrBullwinkle,  I can get the populating of the skills and the ability to multi-select.  However, once I select, it will not populate table 3.

@capricorn1, I am not sure I follow.  How would this tie back to my main table in Table 3?
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
to add multiple skills, using multi select listbox and vba

with me.lstskills
      if .itemsselected.count > 0 then
         for each j in .itemsselected
               currentdb.execute "Insert into tableName([ID], skill) values(" & me.[ID] &", '" & .column(1,j) &"')"
         next

      end if



end with
0
 

Author Comment

by:gracie1972
Comment Utility
I am getting a too few parameters error.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
<I am getting a too few parameters error. >

make sure that the field names and table names are spelled correctly and, that the name of the field you are using are in the table.
0
 

Author Comment

by:gracie1972
Comment Utility
I added this to my combo box (on enter) event procedure:

My table is tblResources:
ID
Skills

In the  " & Me.[ID] & ", '" &
Is ID the Skills ID or Resource ID?


---------------------------------------------------------------------------------
Private Sub lstskills_Enter()
With Me.lstSkills
      If .ItemsSelected.Count > 0 Then
         For Each j In .ItemsSelected
               CurrentDb.Execute "Insert into tblResources([ID], Skills) values(" & Me.[ID] & ", '" & .Column(1, j) & "')"
         Next

      End If

End With

End Sub
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
what is the rowsource of the listbox?

what is the recordsource of the form?
0
 

Author Comment

by:gracie1972
Comment Utility
List Box:
SELECT [tblSkills].[ID], [tblSkills].[Abbr] FROM [tblSkills] ORDER BY [Abbr];

Record Source of Form:
tblResources
0
 
LVL 29

Expert Comment

by:IrogSinta
Comment Utility
Since your from is bound to tblResources, if you have a textbox called txtSkills (bound to [Abbr]), you can use this:

Private Sub lstSkills_AfterUpdate()
    With Me.lstSkills
      If .ItemsSelected.Count > 0 Then
         For Each j In .ItemsSelected
            Me.txtSkills = Me.txtSkills & .Column(1, j) & ", "
         Next
      End If
    End With
End Sub

Open in new window

0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:gracie1972
Comment Utility
That partially worked, however the only thing that saved to my table was , , ,.  
The data did not save.  

Also the fields stayed highlighted after I selected them for all the records as well.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
upload a copy of your db, and give details about the process you are trying to do.
0
 
LVL 29

Expert Comment

by:IrogSinta
Comment Utility
To save the record, add:
Dirty = False
To clear the list box selections, use:
Me.lstSkills=Null
0
 

Author Comment

by:gracie1972
Comment Utility
@Capricorn1

I am trying something new to accomplish my task. I am uploading my db.
My main objective is to track skills by each resource.

I have three tables.
Tables:
tblResources
      ResourceID
tblResourcesSkills
      ResourceID  >> Same as ResourceID in tblResources
      SkillsID
      Skill
tblSkills
      SkillsID >>Same as SkillsID in tblResourcesSkills
       Abbr  >>>Same as Skills in tblResourcesSkills

Forms:
Main Form to add resources:   frmResources
    >> This is the form that needs to be able to add skills from the resources (tblResources) and stored in (tblResourcesSkills)

I included the old way that I is listed in this thread.  However, it stores the data , , ,.  Ultametly this will not work if I need to run a report by Skill.  

I am trying to add check boxes.  Each check box is tied to tblSkills, but needs to update to tblResourceSkills.  I am not sure if this is possible?


Main Form in Database linked to all my subForms: frmNACSResources
Sub-Form to view skills: frmSkillsResourcesSubform

These forms are linked to each other for viewing purposes.

I have un-hidden the navagation and there is a login when you open the db.  
login: angelam
pw: 123456

If you know of a better way to accomplish this please let me know. It has been a few years since I have developed in Access.
NACS-Resource-DB---Copy.mdb
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 500 total points
Comment Utility
Here's a revised database.  I created a new subform so you don't need the other one.  I also did not use the SkillID fields in your tblResourceSkills and tblSkills since the Abbr field itself is a unique field.
NACS-Resource-DB---Copy.mdb
0
 

Author Comment

by:gracie1972
Comment Utility
Thank You  That does exactly what I needed to.
0
 

Author Comment

by:gracie1972
Comment Utility
@ IrogSinta  I have one final question, can I message you?  My business contact wanted to add an additional layer and I am not quite sure how to modify it.  I have tried in the code.

tblResourcesSkills they wanted to add a free text box (Other) so that when we choose Other  as a choice they can free text additional information.  So it would add an additional layer of  including what is entered into Other. (Other is linked to [Abbr] (OTH) & [OTHER] (Other).

I can add a check box
chk10 which is linked to [Abbr]  OTH
and I added a text box next to it (txtOther)

The field txtOther would upated in tblResourcesSkills would be (Other)  which is linked to Abbr.OTR

Can this be done?
0
 

Author Comment

by:gracie1972
Comment Utility
Never mind, I figured it out :-)
0
 

Author Comment

by:gracie1972
Comment Utility
@ IrogSinta

My check boxes stay checked when I go to add a new record.  When I go to review an existing record they default back to unchecked.  Any ideas?
0
 
LVL 29

Expert Comment

by:IrogSinta
Comment Utility
Just change the OnCurrent event to:
Call HighlightSkills
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now