#ERROR

  • Thread starter Thread starter Bill Stanton
  • Start date Start date
B

Bill Stanton

I have a form where one of the fields
ControlSource is:

=fmtDVal([DateVal])

where fmtDVal is a public function:

Public Function fmtDVal(DVal As Date) As String
fmtDVal = MonthName(Month(DVal), True) & " " & Day(DVal)
End Function

and, DateVal is a number field returned from the
query serving as the RecordSource for the form.

fmtDVal tests okay, as in fmtDVal(37815) would
return "Jul 13" as expected.

The text box is named "DateVal".

I cannot find why I continue to get #ERROR when
I open the form.

I've checked everything suggested in the HELP text
for #ERROR, but found nothing violated.

Any ideas or suggestions?

Thanks,
Bill
 
Bill,
regarding:
and, DateVal is a number field returned from the
query serving as the RecordSource for the form.

fmtDVal tests okay, as in fmtDVal(37815) would
return "Jul 13" as expected.

The text box is named "DateVal". <

That's your problem.
Access is confused.
You have a field named [DateVal] and a control with an expression named
'DateVal'.
Change the control name to something else, perhaps 'txtDateValue'.

But why are you going through these hoops to get the Month and Day on your
form.

Try a control source of
=Format([DateVal],"mmm d")
and avoid the user defined function completely.
Or ...
just use [DateVal] as control source and set the control's format property
to
mmm d


--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Bill Stanton said:
I have a form where one of the fields
ControlSource is:

=fmtDVal([DateVal])

where fmtDVal is a public function:

Public Function fmtDVal(DVal As Date) As String
fmtDVal = MonthName(Month(DVal), True) & " " & Day(DVal)
End Function

and, DateVal is a number field returned from the
query serving as the RecordSource for the form.

fmtDVal tests okay, as in fmtDVal(37815) would
return "Jul 13" as expected.

The text box is named "DateVal".

I cannot find why I continue to get #ERROR when
I open the form.

I've checked everything suggested in the HELP text
for #ERROR, but found nothing violated.

Any ideas or suggestions?

Thanks,
Bill
 
You have given the explanation in your question. If DateVal is a number then
you cannot hope to pass it to a function that requires a parameter of type
Date. If this number in some way represents a date you could use CDate to
convert it. Alternatively, re-write fmtDVal to accept a number.
 
Fred,
Try a control source of
=Format([DateVal],"mmm d")
and avoid the user defined function completely.
Or ...
just use [DateVal] as control source and set the control's format property
to
mmm d

I didn't know the two options you mentioned existed... I do now and
the latter one worked just fine.

Thanks,
Bill


Fredg said:
Bill,
regarding:
and, DateVal is a number field returned from the
query serving as the RecordSource for the form.

fmtDVal tests okay, as in fmtDVal(37815) would
return "Jul 13" as expected.

The text box is named "DateVal". <

That's your problem.
Access is confused.
You have a field named [DateVal] and a control with an expression named
'DateVal'.
Change the control name to something else, perhaps 'txtDateValue'.

But why are you going through these hoops to get the Month and Day on your
form.

Try a control source of
=Format([DateVal],"mmm d")
and avoid the user defined function completely.
Or ...
just use [DateVal] as control source and set the control's format property
to
mmm d


--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Bill Stanton said:
I have a form where one of the fields
ControlSource is:

=fmtDVal([DateVal])

where fmtDVal is a public function:

Public Function fmtDVal(DVal As Date) As String
fmtDVal = MonthName(Month(DVal), True) & " " & Day(DVal)
End Function

and, DateVal is a number field returned from the
query serving as the RecordSource for the form.

fmtDVal tests okay, as in fmtDVal(37815) would
return "Jul 13" as expected.

The text box is named "DateVal".

I cannot find why I continue to get #ERROR when
I open the form.

I've checked everything suggested in the HELP text
for #ERROR, but found nothing violated.

Any ideas or suggestions?

Thanks,
Bill
 
Back
Top