Dates

  • Thread starter Thread starter Pastor Del
  • Start date Start date
P

Pastor Del

I get an error msg when executing the following code. (This is part of the
code for a command button on a form called frmDocLog)

Dim datDate as Date
datDate=Date

The error tells me that Access cannot find the field 'Date' referred to in
my expression.

The problem may be that the form's record source, tblDocs, has a field named
Date. But, even when I rename this field the problem still existed.

Is this the problem, and if so, how can I fix it?
 
I get an error msg when executing the following code. (This is part of the
code for a command button on a form called frmDocLog)

Dim datDate as Date
datDate=Date

The error tells me that Access cannot find the field 'Date' referred to in
my expression.

The problem may be that the form's record source, tblDocs, has a field named
Date. But, even when I rename this field the problem still existed.

Is this the problem, and if so, how can I fix it?

Date is a reserved word for this very reason. Access can't tell if you mean
the builtin function Date() or the field.

Ideally, change the fieldname to something other than a reserved word; if you
can't, try datDate = DAO.Date() to explicitly reference the function.
 
Access has no idea what datDate is. When working with controls, you have to
refer to them using proper syntax. For example...

[Forms]![formName]![datDate]
[Forms]![formName].Controls("datDate")
Forms(FormName).Controls("datDate")
Me.datDate
Me.controls("datDate")

Set d = [Forms]![formName]![datDate]

There's a wide variety of ways of referring to the control, but you can't
just use the control name. Without the qualifying syntax, access doesn't know
if you're referring to a control or a variable.
 
What John wrote is still applicable though. I just misread the DIM. My
response is a perfect example of John's comment. I read the statement datDate
= Date as if you're trying to set a control to the value of the Date()
function.

David H said:
Access has no idea what datDate is. When working with controls, you have to
refer to them using proper syntax. For example...

[Forms]![formName]![datDate]
[Forms]![formName].Controls("datDate")
Forms(FormName).Controls("datDate")
Me.datDate
Me.controls("datDate")

Set d = [Forms]![formName]![datDate]

There's a wide variety of ways of referring to the control, but you can't
just use the control name. Without the qualifying syntax, access doesn't know
if you're referring to a control or a variable.

Pastor Del said:
I get an error msg when executing the following code. (This is part of the
code for a command button on a form called frmDocLog)

Dim datDate as Date
datDate=Date

The error tells me that Access cannot find the field 'Date' referred to in
my expression.

The problem may be that the form's record source, tblDocs, has a field named
Date. But, even when I rename this field the problem still existed.

Is this the problem, and if so, how can I fix it?
 
Back
Top