Naming Convention!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I inherited a database that has poop naming conventions e.g., using Date as a
field name.

My problem now is I have to create a function and use that name but am
having an error
Public Function Weekends(Date as Date , RcvdDate As Date) As Integer

How do I take care of this?
 
Just because the field you're going to pass to the function is named Date
doesn't mean you need to name the function's parameter Date:

Public Function Weekends(Date1 as Date , RcvdDate As Date) As Integer
 
The argument names in your function declaration don't need to match the
names of any fields. You could just say:

Public Function Weekends(d1 as Date , d2 As Date) As Integer

However, I strongly recommend that you take the time to fix the field names.
Since you have "inherited" the database, it will same you lots of heartache
further down the track.
 
Forgive me if I am wrong or misunderstood you here but I would like to use
use the Date(which was the name of the field in the table) in my function so
that I can reference that function in my query...

e.g., the following is what I used to subtract holidays from "Date"
Public Function Holidays2(Date As Date) As Integer

Holidays = DCount("*", "Holiday", "HdyDate Between " & _
Format$(Date, "\#mm\/dd\/yyyy\#") & _
" And " & Format$(Date, "\#mm\/dd\/yyyy\#") & _
" And Weekday(HdyDate, 1) <> 1 " & " And Weekday(HdyDate, 1) <>
7 ")

End Function
 
In this Dcount the Date is not a name of a field in the table, it used as a
variable, so all you need to do is change the name of the Date in the
function declaretion and inside the function.
The name of the field in the table is HdyDate, and you are not changing it

But it look like one of the Date in the between is a real Date() value, that
should return the current date, so you have to decide if the Date is the End
Date of Start date.


Public Function Holidays2(Date1 As Date) As Integer

Holidays = DCount("*", "Holiday", "HdyDate Between " & _
Format$(Date1, "\#mm\/dd\/yyyy\#") & _
" And " & Format$(Date(), "\#mm\/dd\/yyyy\#") & _
" And Weekday(HdyDate, 1) <> 1 And Weekday(HdyDate, 1) <>
7 ")

End Function
 
OOOh now I understand.... Thanks...

Graham Mandeno said:
The argument names in your function declaration don't need to match the
names of any fields. You could just say:

Public Function Weekends(d1 as Date , d2 As Date) As Integer

However, I strongly recommend that you take the time to fix the field names.
Since you have "inherited" the database, it will same you lots of heartache
further down the track.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

JOM said:
I inherited a database that has poop naming conventions e.g., using Date as
a
field name.

My problem now is I have to create a function and use that name but am
having an error
Public Function Weekends(Date as Date , RcvdDate As Date) As Integer

How do I take care of this?
 
JOM said:
I inherited a database that has poop naming conventions e.g., using Date as a
field name.

You've already got your immediate answer but just to stir things up a
bit. <smile>

Tony's Table and Field Naming Conventions
http://www.granite.ab.ca/access/tablefieldnaming.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 
But, I don't think anyone has mentioned that it is a Bad Idea to use an
Access reserved word as a Field Name and Date is an Access reserved word.

Larry Linson
Microsoft Access MVP



JOM said:
OOOh now I understand.... Thanks...

Graham Mandeno said:
The argument names in your function declaration don't need to match the
names of any fields. You could just say:

Public Function Weekends(d1 as Date , d2 As Date) As Integer

However, I strongly recommend that you take the time to fix the field
names.
Since you have "inherited" the database, it will same you lots of
heartache
further down the track.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

JOM said:
I inherited a database that has poop naming conventions e.g., using Date
as
a
field name.

My problem now is I have to create a function and use that name but am
having an error
Public Function Weekends(Date as Date , RcvdDate As Date) As Integer

How do I take care of this?
 
Back
Top