?
Solved

Add and maintain records in a second table to show chronology of changes to project using sub form in main form

Posted on 2004-08-03
4
Medium Priority
?
244 Views
Last Modified: 2006-11-17
I want to be able to select a project record in table one and copy it to table two and then make changes to the project information stored in table two (all fields are the same in the two tables with different names to distinguish between original project information and changed project information). Then I want the user to be able to select the same project in table one becuase there is another change to be made and have Access check the second table for the same project number. If the project number is found, then check the number in a second field for the number of revisions and copy the original project record into the second table as the next revision number. The intent is to be able to show all the revisions made to the original project keeping track of the sequence of the revisions.

Example: Original project number "AA1001" in table one is copied to table two as "AA1001" in one field and revision "1"  in second field to be displayed as "AA1001.1" using concatenation in textbox on form. Then when the next change to the project is necessary, Access checks for "AA001" in table two and if found then finds the last revision number in second field and adds the project as "AA1001.2" keeping revision .1 and .2 in table two to review the sequence of the changes.

I have used the findfirst_nomatch routine in Access help and can get close to a solution, but having a hard time getting to the point of finding last revision of the project and adding "1" to the revision number and storing the project in table two so I can display it in the subform under the main form to make the changes.

Any suggestions?
0
Comment
Question by:richardlh
[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 Comments
 
LVL 4

Assisted Solution

by:davidW
davidW earned 375 total points
ID: 11711560
if you have/had a field for 'revision no' and this field is hidden in subform2
the concatenation would be 'Project No' & 'revision no'/10 or/100 0r /1000
( depending on the upper limit of possible revisions.

you should then be able to use findlast and simply add 1 to the answer

( or alternatively i am not understanding the problem )

0
 

Author Comment

by:richardlh
ID: 11711670
David,

I expect that the number of revisions will not exceed a two digit number and more likely not exceed 10. I use the concatenated value "=[LOCID] & "-" & [ProjectNumber] & "." & [RevisionNumber] in the subform and "=[LOCID] & "-" & [ProjectNumber] in the main form so the user can have confidence that the two projects represent the original.

I understand that the result of the findfirst, findnext, etc are boolean and are true or false. When I try to Debug.Print the results from a recordset find method, I can a print out of all records but cannot go to a specific record. I tried to use varbookmark = .bookmark then print the record of interest, but no luck.

I am using an SQL statement in an openrecordset statement. I probably need to post the code here that I am using.
0
 
LVL 8

Accepted Solution

by:
Eric Flamm earned 375 total points
ID: 11711723
Once you've identified the project number, you can create a recordset from Table2 for all records with that number:

strSQL="SELECT * from Table2 where ProjectNo=" & txtProjectNo & " Order By RevisionNo"
set rst2=db.openrecordset(strSQL)

txtProjectNo comes from your selection form

Then, test to see if there are any records in the recordset:

If rst2.EOF and rst2.BOF then   'No records in recordset, so Revision=1
  intRevision=1
Else
   rst2.movelast
   intRevision=rst("RevisionNo")+1
End if

Then, add the new record to Table2
set rst2=db.openrecordset(Table2)
rst2.add
rst2("RevisionNo")=intRevision
... 'Fill in the rest of the fields here from your selection form or Table1
rst2.Update

Finally, display the new record in your subform - using txtProjectNo and intRevision as filter criteria

-ef
 
0

Featured Post

Industry Leaders: 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!

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 …
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

719 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