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
194 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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.

762 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

11 Experts available now in Live!

Get 1:1 Help Now