Month Function in access

E

emailgadjet

Access 2000 is driving me nuts.

I'm trying to add the month to a field on a form using

myMonth = Month(Me.Problem_Date) or myMonth = Month(Date) or myMonth =
Month(now())

None of the above work. I always get a type mismatch error.

myMonth is dimensioned as a string and I put the value into a textbox
later, or I would if I could get it to work.


I've used a simlar process to get the Day:-

myDay = Weekday(Now(), 2)

That works great.

Anyone any ideas?

Cheers,
Phil
 
M

Marshall Barton

Access 2000 is driving me nuts.

I'm trying to add the month to a field on a form using

myMonth = Month(Me.Problem_Date) or myMonth = Month(Date) or myMonth =
Month(now())

None of the above work. I always get a type mismatch error.

myMonth is dimensioned as a string and I put the value into a textbox
later, or I would if I could get it to work.


I've used a simlar process to get the Day:-

myDay = Weekday(Now(), 2)


The Month function returns the number of the month (1 thru
12). If you want the month name, I think A2K has a
MonthName function, or you can use Format(Date, "mmmm")
 
F

fredg

Access 2000 is driving me nuts.

I'm trying to add the month to a field on a form using

myMonth = Month(Me.Problem_Date) or myMonth = Month(Date) or myMonth =
Month(now())

None of the above work. I always get a type mismatch error.

myMonth is dimensioned as a string and I put the value into a textbox
later, or I would if I could get it to work.

I've used a simlar process to get the Day:-

myDay = Weekday(Now(), 2)

That works great.

Anyone any ideas?

Cheers,
Phil

MyMonth should not be a string variable because Month() returns an
Integer number.

Dim MyMonth as Variant
MyMonth = Month(Date)
MyMonth = 3

If this still gives an error than you may have a missing reference.

Open any module in Design view.
On the Tools menu, click References.
Click to clear the check box for the type library or object library
marked as "Missing:."

An alternative to removing the reference is to restore the referenced
file to the path specified in the References dialog box. If the
referenced file is in a new location, clear the "Missing:" reference
and create a new reference to the file in its new folder.

See Microsoft KnowledgeBase articles:
283115 'ACC2002: References That You Must Set When You Work with
Microsoft
Access'
Or for Access 97:
175484 'References to Set When Working With Microsoft Access' for
the correct ones needed,
and
160870 'VBA Functions Break in Database with Missing References' for
how to reset a missing one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top