PDA

View Full Version : Solved: Richardall: Form Field



Zack Barresse
06-24-2005, 02:23 PM
Posted on behalf of Richardall by firefytr.

I would like to make a form field that holds a date. I would like the format to be mm/dd/yyyy.

When you tab into the field, I would like a response box to ask "today" yes or no. If the answer is yes, I would like the field to be filled with today?s date. If no, I would like a drop down calendar to appear and the date can be chosen from that calendar. The chosen date will go in the field.

Once filed in, the macro will set the date to the mentioned format, will tab to the next field and exit.

Any help or suggested code would be greatly appreciated.

Richard

xCav8r
06-24-2005, 02:40 PM
A form like in Word or a VB UserForm?

MOS MASTER
06-25-2005, 12:32 PM
Hi Zack & Richard, :yes

This can be done with a calendarcontrol on a userform.

In a codemodule:
Option Explicit
Public sName As String
Sub CheckDate()
sName = vbNullString
sName = Selection.Bookmarks(1).Name

If MsgBox("Insert today", vbYesNo + vbQuestion, "Insert Date") = vbYes Then
ActiveDocument.FormFields(sName).Result = Date
Else
frmCalendar.Show
End If

ActiveDocument.FormFields(sName).Next.Select
End Sub


In the UserForm
Option Explicit
Private Sub Calendar1_Click()
ActiveDocument.FormFields(sName).Result = Calendar1.Value
Unload Me
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Calendar1.Value = Date
End Sub


The mask in the formfield will take care of the desired date format.

See attachment.

Enjoy! :whistle:

fumei
06-27-2005, 06:51 AM
You need to make a reference to MSCAL.OCX to use the Calendar control. It is not a standard reference.

MOS MASTER
06-27-2005, 08:43 AM
You need to make a reference to MSCAL.OCX to use the Calendar control. It is not a standard reference.
Hi Gerry, :yes

True..I didn't mention that because Zack asked for a calander control so I figured he knows...

But you're right I should mention these things..:whistle:

Zack Barresse
06-28-2005, 09:01 AM
..I didn't mention that because Zack asked for a calander control so I figured he knows...
I do not need to know personally. This question was originally posted as an Article by Richardall and I thought it belonged in the Word forum. So I posted what he wrote (copy/paste) and pm'd the user. :)

MOS MASTER
06-28-2005, 09:03 AM
I do not need to know personally. This question was originally posted as an Article by Richardall and I thought it belonged in the Word forum. So I posted what he wrote (copy/paste) and pm'd the user. :)
Thanx for clearing the matter..:yes

I thought Richard was a friend of yours or something...it was kinda unusual...

So Ok Richard...did the code help you? :whistle:

Richardall
06-30-2005, 11:55 AM
Yes, the suggestions helped and after a little playing, the form is working and off to help a coworker. Thank you for all the help and suggestions.

If I could ask one mor question, why doens't this work on a Mac? I sent the file to 5 peolple with different versions of word and the only persone that couldn't get it to work was the mac user.

Please suggest a fix?

Regards,
Richard

MOS MASTER
06-30-2005, 12:00 PM
Hi Richard, :yes

You're most welcome.

I think it doesn't work on the mac (Guess cause I don't own a mac) because it doesn't have or support MSCAL.OCX (Part of Access Installation)

Did you check if it was there and properly registerd?

We have 2 MAC wizards over here Blue Cactus & Shades. I sugest you mark this thread solved and post the document and your question over at the Mac questions part of this site.

I'm sure they can help you..I'm just guessing!

Later..:whistle:

Richardall
06-30-2005, 01:13 PM
I would like to post the thread as closed but the pull-down isn't shown.

I get three options, printable version, email this page and subscripbe to thread.

Am I doing something wrong? I'm loged in.

Richard

MOS MASTER
06-30-2005, 01:18 PM
Hi Richard, :yes

That's strange but it has happened before..

I'll Ask one of the Admins to do it for you and look at your profile if they perhaps can find the cause of your problem.

Later..:whistle:

Jacob Hilderbrand
06-30-2005, 01:26 PM
Richard

What browser are you using?

Richardall
06-30-2005, 01:47 PM
I didn't actually start the post. Firefytr posted it for me because I'm new and put it in the wrong place. I think he has the ability to close it.

I opened a new thread and in that one, I have the ability to close.

I think Firefytr will need to click the close button?

Richard

MOS MASTER
06-30-2005, 02:08 PM
Hi Richard, :yes

You're absolutly right!
I totally forgot about that. (It is a unusual situation)

Glad to see it does work for you. BTW Jake allready marked the thread solved..

Tada..:whistle: