Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Create a new record with Combo Box

Posted on 2011-09-21
12
Medium Priority
?
354 Views
Last Modified: 2012-05-12
Hi Guys,
I have two tables, Employees table and Stipend table. On my form I have a combo box to find the related data per employee.  What I would like to do is a button that when I click on it , it will clear the form and based on my combo box selection(employee name) to create a new stipend.
Both files are linked with the FileNo which is the id no of employee.  Thanks in advance.
0
Comment
Question by:Sheogorath
[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
  • 7
  • 5
12 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36576630
I will presum a standard set up where you are "referencing" the Employee ID in the combobox, but simply "displaying" the name.
Then try something like this

DoCmd.GoToRecord , , acNewRec
Me.txtEmpID = Me.cboEmployee
0
 

Author Comment

by:Sheogorath
ID: 36584665
Thank you but I am getting an error The Microsoft Office Access database engine cannot find a record in the table 'Employees' with key matching field(s) 'Stipend.FileNo'.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36585128
Post a sample of your DB as it stands now.

Sample database notes:
1. Back up your database(s).
2. Combine the front and back ends into one database file.
3. Remove any startup options, unless they are relevant to the issue.
4. Remove any records unless they are relevant to the issue.
5. Delete any objects that do not relate directly to the issue.
6. Remove any references to any "linked" files (files outside of the database, Images, OLE Files, ...etc)
7. Remove any references to any third party Active-x Controls (unless they are relevant to the issue)
8. Remove, obfuscate, encrypt, or otherwise disguise, any sensitive data.
9. Compile the code. (From the VBA code window, click: Debug-->Compile)
10. Run the compact/Repair utility.
11. Remove any Passwords and/or security.
12. If a form is involved in the issue, set the Modal and Popup properties to: No
    (Again, unless these properties are associated with the issue)
13. Post the explicit steps to replicate the issue.
14. Test the database before posting.

In other words, ...post a database that we can easily open and immediately see and/or troubleshoot the issue.
And if applicable, also include a clear graphical representation of the *Exact* results you are expecting, based on the sample data.

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Sheogorath
ID: 36588443
Thank you. Please see attached.
Sample-DB.accdb
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36588588
Sorry, I can't seem to follow your design here...
Are you quite sure your tables are properly designed normalized and related?

What is the ultimate goal here again? (based on the DB you posted)
0
 

Author Comment

by:Sheogorath
ID: 36588624
Hehe Well,I am not sure!;) This is my first time working on access.  What I would like to do is based on the Employees ID create Stipends.
I would like to select the employee from the Combobox edit if necessary if not create a new stipend.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36588683
<Hehe Well,I am not sure!;) This is my first time working on access. >
...Then I suggest that you verify the design *First* before ever thinking about forms...

If the design is flawed, then the form will never work anyway...

In a *very general* sense, ...If one Employee can have many stipends, then this is a basic One to Many Relationship.
You have this already, but I am concerned about the primary key in the employees table (File Number)?
Is this unique to each employee?  If so, then why not call it EmpID, to avoid confusion...?
0
 

Author Comment

by:Sheogorath
ID: 36588754
Yes it is unique. I did change the FileNo to EmpID and I believe I changed it every where but still giving me this error. :S



SShot.jpg
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 2000 total points
ID: 36590007
See this sample

Once the main and subforms are working correctly, Select the employee from the combobox, then simply click the "*" (New record button) on the subform to create a new stipend for the selected Employee.

Again, your main concern here should be with the table design, not the forms.

When/If the table design is updated, the forms may have to be redesigned anyway.

Again, this is all database basics...


JeffCoachman
Sample-DB-2-.mdb
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 2000 total points
ID: 36592918
If you want this done by a button on the main form:

1. Drop a button on the main form
2. Insert code like this on the Click event:

Me.frmStipendSub.SetFocus
DoCmd.GoToRecord , , acNewRec
[frmStipendSub].Form![StipendAmount].SetFocus


;-)


Jeff
0
 

Author Comment

by:Sheogorath
ID: 36593403
Thanks for all the help.:) I created a new form from Employees table and created Stipends form and made the Stipends form Subform. Now it works as it is supposed to and I am able to add new records.Yayy!:)) Now I can ask some other questions hehhe
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36594201
<Now I can ask some other questions >
Yes, about the design...

Your objective should be to describe the function/purpose of the database in general.
It is not clear if the other three tables are designed and linked properly.

JeffCoachman
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
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 …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

618 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