Form viewed -history

A

Accesser

Hi. I have a selfmade crm system. It has a main form that has subfors on
different pages. I would like to make history log of viewed companies so that
it is easy to scroll back the list and pick company that was viewed recently.
List could open vie button. This feature is useful because we make alot of
phone calls and if the person is not answering right away but calls back in
few minutes, it would be easy to go back the "viewed list". I would like to
make list of viewed companies, not edited or changed history. Many Thanks in
advance. Great forum!
 
S

Scott Lichtenberg

You'll need a table to hold the recorded data. It will need fields for
company, date/time viewed, and any other information you want. On your main
form, add code to the OnCurrent event. The OnCurrent event is executed as
you move into a record, so every time a user selects a company, this event
will fire. Your code should look something like the following:

Dim db as Database
Dim rs as MyLogTable

Set db = CurrentDb
Set rs = db.OpenRecordset("MyLogTable", dbOpenDynaset)

rs.AddNew
rs!CompanyID = Me!CompanyID
rs!DateTimeViewed = Now
{set you other fields here}

rs.Update

Set rs = Nothing
Set db = Nothing

Hope this helps.
 
A

Accesser

Thanks alot Scott!!! I'll try this asap. Again, great forum.

"Scott Lichtenberg" kirjoitti:
 
A

Accesser

Thanks ones more Scott. I've got rid of the "Dim rs as MyLogTable" -line
because it caused compile error. As soon I removed it, it worked perfect.
Don't know why this happened?

"Scott Lichtenberg" kirjoitti:
 
J

John Spencer

Try
Dim rs as DAO.Recordset



'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 
A

Accesser

Now it seems that it worked in my test file it worked but some how it doesn't
work in my crm. Dim db... and Dim rs... gives both the compiler error.
Strange. Can anyone help me with this?

"Scott Lichtenberg" kirjoitti:
 
J

John Spencer

Try
Dim db as DAO.Database
Dim rs as DAO.Recordset

AND make sure your database references the DAO library. TOOLS:
References in the VBA window - Microsoft DAO n.n Object Library

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 
A

Accesser

Thanks John. I solved the problem with your help. Worked just fine.

"John Spencer" kirjoitti:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top