Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's the best way to create a history table?

Status
Not open for further replies.

rgomez1999

Technical User
May 25, 2000
66
US
I'm working on a project where my clients come everyday to see me.&nbsp;&nbsp;On my form I have a field called Date of Visit (short date format) with the source as being =Date() which puts in today's date (PC Date).&nbsp;&nbsp;Then I have a command button that prints a billing form but I'd also like this command button to post that visit date into a history table.&nbsp;&nbsp;So when I ask Access how many visits did John Doe have in May 2000 I can get those dates that he came.&nbsp;&nbsp;I tried creating a separate table called tblHistoryVisits and the PatientID is the primary key for that table and the main patient table.&nbsp;&nbsp;In my patient table I added the field DateVisit and I also added that field to the tblHistoryVisits. I created a relationship with the PatientID as the source for both tables but it doesn't post the DateVisit from the main patient table to tblHistoryVisit.<br><br>Any help is appreciated.<br>
 
You have to explicitly put the data in that table.<br>This code will do that.<br>-----------------------<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim MyDB As Database, MySet As Recordset<br>&nbsp;&nbsp;&nbsp;&nbsp;Set MyDB = CurrentDb<br>&nbsp;&nbsp;&nbsp;&nbsp;Set MySet = MyDB.OpenRecordset(&quot;tblHistoryVisits&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MySet.AddNew<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MySet!PatientID = Me!PatientID&nbsp;&nbsp;&nbsp;'Patient ID on main form<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MySet!DateVisit = Me!DateVisit&nbsp;&nbsp;&nbsp;' Date on main form<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MySet.Update<br>&nbsp;&nbsp;&nbsp;&nbsp;MySet.Close<br>&nbsp;&nbsp;&nbsp;&nbsp;MyDB.Close<br>------------------------------<br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Thanks for the response Doug, quick question, I'm using Access 2000 will I have a problem with this code? Secondly where exactly do I enter this code? Is it an On Click Code procedure? <br><br>robg<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top