Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access 2007, Form with with Combobox Filters and Unbound Text Box and Unbound combo box update of original record

Posted on 2010-09-11
8
Medium Priority
?
617 Views
Last Modified: 2013-11-28
Hello to all the Experts!!!  Hope your weekend is great.

I've created a Form that has 2 Combo Boxes that look to 2 table in order to filter down to a particular record.  [For the sake of this question let's say it's the 5th record of a particular Employee]

Once that occurs, on the Form the Manager is to Complete an Unbound Text Box for Comments and then Click a "Save" button. The Save button is Assigned to a Macro that has the following:

Condition ------------------------ Action ------------------------ Argument
{blank} ------------------------- OnError ------------------------- Next
{blank} ------------------------- RunCommand ------------------SaveRecord
[MacroError]<>0 -------------- MsgBox ---------------------- =[MacroError].Description],Yes,None,


I get no errors but it is NOT updating the filtered record. It is updating whatever is the first record for that employee Not the filtered to record.  Additionally, the Date & Time field is not being updated with the Now() default value when it updates that record.

Do I have to convert this macro to an "Event Procedure" for that Command button so that it will update the appropriate record? or is there a way in the Macro to take care of it updating the "Filtered" record.

0
Comment
Question by:wlwebb
[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
  • 4
  • 3
8 Comments
 
LVL 10

Expert Comment

by:conagraman
ID: 33654637
for starters an unbound anything wont update a record because it is just that unbound. a control source needs to be assigned to it.

other than that can you upload a sample database to look at? this will help to know what is going on.
0
 
LVL 16

Expert Comment

by:Sheils
ID: 33654868
It is possible to update a record from unbounded control. You do this by using an update query. I can't remember the last time I have used a macro in access because using event procedure gives you so much more flexibility it not worth bothering about macro.

Having said that using a bounded textbox would have made you life a lot easier. There would be a lot less codes to worry about. One option might be to nest a bounded form inside the unbounded filter form.

0
 
LVL 16

Accepted Solution

by:
Sheils earned 2000 total points
ID: 33655022
I have created a sample db that illustrates the use of an unbounded form to direct where the comments will go. The controls on the subform can be made invisible.
dbFilterForm.mdb
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:wlwebb
ID: 33655227
sb9
An obvious comment first.  I AM completely new to Access.  With that, I notice a lot of times that dbs that are uploaded by experienced coders such as yourself don't have "relationships" from one table to the next.

Seems that all of that is being done via VB code instead of adding a field with a Lookup in the first table to the associated second table.
 
Example, in the db you presented dbFilterForm, on the tblComment,  fldNameID is not "Linked" through a "lookup"  to tblName.

For my own education, is that normal.  And if it is, then is it to make the db run faster after it has hundreds upon hundreds of records in it?  Or did you simply do that to replicate an example based upon what I was referring to?

Just trying to learn why.

Thanks for the example
0
 
LVL 16

Expert Comment

by:Sheils
ID: 33655432
Hi wlwebb

Firstly thanks for the compliment. In reality I can hardly call myself a coder, you should see what the other guys on EE can do, its mind blowing. I having been coding for about 3 years and it was pretty daunting to start off. But it gets easier and somehow addictive once you get into it.

Anyway, back to your question;The best way to construct a database is to ensure proper relationship. If this was part of a database that I had constructed as a hold it would definitely have a one-to-many relationship set between tblName and tblComments.

In this particular example I did not create a relationship because it was not required for the purpose of demonstrating the solution to your question. Having said that you can (and I recommend you to) set a relationship between the two tables and the proposed solution will still work with any modification required.

0
 
LVL 16

Expert Comment

by:Sheils
ID: 33655485
Hi wlwebb

Regarding my first statement about using an update query to update records from an unbounded form. Check the first example from the following link:

http://www.databasedev.co.uk/forms.html

This is a good website for Access newbies, it explains things in plain English and gives you a lot of examples to download so that you can see what the codes are doing
0
 

Author Comment

by:wlwebb
ID: 33656924
sb9

Sorry for the delay in responding.  Sleep deprivation finally set in.  Thank you for the insight.  I was beginning to wonder if my setting all the "Lookups" in my tables was going to cause me pains down the road.  I will review the latest example and try to apply it to my situation.

Again, many thanks.
0
 

Author Closing Comment

by:wlwebb
ID: 33656928
sb9 gave clear instructions and provided great on point examples that were simple to follow and apply to my problem
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

730 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