Go Premium for a chance to win a PS4. Enter to Win

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
?
620 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 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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.
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.
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…

927 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