Problem with Fuction information

  • Thread starter Thread starter scott04
  • Start date Start date
S

scott04

Hi everyone,
I have been asked to calculate turntime for a database that i did not
create. Here are the names of the fields:
Date/Time of Call
Date Processed

My problem is that these fields contain spaces rather than underscores.
When I type in Public Function Workingdays2(Date/Time of Call As Date, Date
Processed As Date) As Integer i received a compile error regarding a list
separator. How would i type a field that has spaces? I always name my
fields with underscores to avoid this problem but how can i get around this
and name the field. Thanks for your help.
 
The name of the parameters in your function has no bearing on the names of
the fields being passed to the function.

You can use

Public Function Workingdays2(CallDate As Date, ProcessedDate As Date) As
Integer

and use CallDate and ProcessedDate everywhere in your function.

To use the function, you'd call

Function([Date/Time of Call], [Date Processed])

Note, though, that if either of the fields are Null, your function will
fail, You may be best off doing something like:

Public Function Workingdays2(CallDate As Variant, ProcessedDate As Variant)
As Integer

If IsNull(CallDate) Or IsNull(ProcessedDate) Then
Workingdays2 = 0
Else

' Put the rest of the code here

End If

End Function
 
Thanks Doug

Douglas J. Steele said:
The name of the parameters in your function has no bearing on the names of
the fields being passed to the function.

You can use

Public Function Workingdays2(CallDate As Date, ProcessedDate As Date) As
Integer

and use CallDate and ProcessedDate everywhere in your function.

To use the function, you'd call

Function([Date/Time of Call], [Date Processed])

Note, though, that if either of the fields are Null, your function will
fail, You may be best off doing something like:

Public Function Workingdays2(CallDate As Variant, ProcessedDate As Variant)
As Integer

If IsNull(CallDate) Or IsNull(ProcessedDate) Then
Workingdays2 = 0
Else

' Put the rest of the code here

End If

End Function


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


scott04 said:
Hi everyone,
I have been asked to calculate turntime for a database that i did not
create. Here are the names of the fields:
Date/Time of Call
Date Processed

My problem is that these fields contain spaces rather than underscores.
When I type in Public Function Workingdays2(Date/Time of Call As Date,
Date
Processed As Date) As Integer i received a compile error regarding a list
separator. How would i type a field that has spaces? I always name my
fields with underscores to avoid this problem but how can i get around
this
and name the field. Thanks for your help.
 
Back
Top