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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically enter dates - 2 questions

Status
Not open for further replies.

ACraib

MIS
Sep 7, 2001
579
GB
Hi

I'm very very new to Access and am trying to create a Call Logging system for the IT Department I work in.

I want to do a couple of things with dates.

1) I have a field called LogDate which I want to automatically enter the current date and time when the record is created.

2) I also have a field called CallStatus (which is a drop down list [lookup]) when I select 'Closed' I want it to automatically as the date and time into a field call CompleteDate ... I'd also, if possible, like to to send an e-mail at this point listing the info from a couple of fields (ProblemType and Solution).

Thanks for your help in advance.

Andrew
 
Andrew,

Set the default value in the TABLE for LogDate to =Now(). That sorts your first problem.....

Now your second.....

I presume that there is some code running when you click on the Closed button? Simple add the line [Forms]![YourFormName]![NameOfTextBoxOnYourFormBoundToCompletedDate} = Now()

And finally.....

Email.....

Well, depends on how you want to code it and what email system you use......the simple way is to use the SendObject method but I much prefer the coded manner.....can you let me have some more details?

Craig

 
Thanks for getting back so quickly.

The first one works like a charm. :)

One the second. What I set up was a table with 3 enteries. The mail database uses the Lookup Wizard to produce a drop down list in the From View of these 3 options. So I don't think there is any code ... well none that I know about ;)

The e-mail system I use is Outlook 2000 running of Exchange 2000. Let me know if you need any more info. Thanks for your help so far.

Andrew
 
Andrew,

Second thing....

Place this code in the After_Update event of your combo box...

If NameOfYourComboBox.Text = "Closed" Then
If IsNull(NameOfFieldWhereYouWantTimeToGo) = True Then
NameOfFieldWhereYouWantTimeToGo = Now()
End If
End If

What it will do is check that the call status, if it is closed, check that it hasn't been set to closed before and a time already exists and if not, paste in the current time....make sense?

And emails.....

What kind of stuff are you looking to email out? Is it data from fields that could be collected in a report?

Craig
 
Craig .. I'd say you we good but your better than that. It's working like a charm. That's made my day ... do you know anything about W2K Domain Controller and GPO's ... don't ask ... it's one of those days.

What I would like to e-mail out (when the CallStatus is set to closed or from a new button 'E-mail Call Report') is something like below

To: [UserWithProblem]
From: ithelpdesk@mycompany.com

Subject: Call Closed [LogNo] [ProblemType]

Body: This call to the help desk has been closed etc etc.


Is that possible? It doesn't have to auto send as I'm sure I can cope with clicking send if I need to ... it would also give me the opportunity to edit the e-mail if necessary

Thanks Again

Andrew
 
And finally....

This needs to go in the After_Update event of the combobox....

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

'Create Outlook Session
Set objOutlook = CreateObject("Outlook.Application")

'Create message
Set objOutlookMsg = objOutlook.CreateItem(Outlook.olMailItem)

'Set attributes for message
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add([Forms]![FormName]![FieldWhereEmailAddressIsKept])
objOutlookRecip.Type = Outlook.olTo
.Subject = "Call " & [Forms]![FormName]![CallNumberField] & " " & [Forms]![FormName]![CallNumberField]
.BodyText = "The above call has been closed by the helpdesk"
.Save .Send End With

Now, it's been a while since I used Outlook automation (we use Groupwise here) but the syntax is from an old piece of code which should work......

You'll need to add a reference to the Outlook type library (look it up in help if you don't know how).....

And if it errors, Debug the code and have a go......it won't be that hard, I promise!!! If you get stuck for property/method name, have a look at the Object Browser....

And if you get REAALY stuck, ask!!

Craig
 
Craig thanks for all your help it's much appreciated.
 
Craig thatnks for all your help ... it's much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top