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
202 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

910 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

23 Experts available now in Live!

Get 1:1 Help Now