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
611 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
  • 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 500 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
 

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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

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…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
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.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

920 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

15 Experts available now in Live!

Get 1:1 Help Now