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
239 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 125 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 125 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

617 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