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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

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

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
richardlh
Asked:
richardlh
2 Solutions
 
davidWCommented:
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
 
richardlhAuthor Commented:
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
 
Eric FlammSenior ConsultantCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now