lebans.com/monthcalendar

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

Guest

Excellent tool. Works great. Instead of the "On Dbl Click" event I entered
the code in the "On Enter" event. My question is;
How doe I avoid this calendar of popping up when there is already a date in
the textbox. (When I open the form in edit mode)
 
You could try checking the field to see if it is null and if so, invoking the
calendar, something like

if isnull([field on form]) then
invoke calendar code
endif
 
That didn't work. Somehow I would like to add some code to one of the modules
so that the calendar will not open when there is already a date in my textbox.
 
Your missing the point here. The ShowMonthCalendar simply shows the
Calendar. Whether you want to show it or not is completely up to you. Do
whatever checks you want prior to calling the function. Check for no date,
check for a valid date...whatever.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
I can only re-iterate what Stephen has said.

You will have placed in your code belonging to the On Enter event the call
to run Stephens calendar code. If you wish to only do this in certain
cirumstances, you need to put into the code the logic to invoke to calendar
when required.

That is why I suggested that you check the field on the form to see whether
there is any data in there. If there is do not call the calendar code, if
there isn't then call it and populate the field.

When you say it didn't work, in what sense do you mean it did not work. Did
the check for null fail, or was there some other reason?
 
Thanks for all the help. I found the answer to my question. But now I have
another question. For some reason I receive the Invalid MonthCalendar object
meesage when I open a record in edit mode and attempt to open the calendar to
add or change a date.
Text message:
The MonthCalendar class instance you passed to this function is INVALID!
You must instantiate the MonthCalendar Class object before you call this
function
The code behind the sample Form shows you how to do this in the Form's load
event.

'This must appear here!
'Create an instance of our Class
Prvate Sub Form_Load()
Set mc = New clsMonthCal
"You must set the class hWndForm prop!!!
mc.hWndForm = Me.hWnd

I do have this code in the Load event. The calendar works on new records.
 
The error message clearly spells out your issue. What part don't you
understand?

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
First of all, I am not as knowledgable as you are. I am just a beginner. My
understanding of the error message is that the code
Set mc = New clsMonthCal
mc.hwndForm = MehWnd
needs to be in the form's Load event, which it is as I wrote before.
 
What the error message is telling you is that you have not created the
instance of the clsMonthCal object. In your example it is the "mc" object
variable. Is there any way that you have code that is setting this object
variable to nothing? Can you copy and paste the code behind your form?

I did not mean to be insulting as to your level of coding skill. It was not
that long ago that I was you.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
I found the mistake I made. Due to my inexperience I added the following to
the code of the Dbl Click Event:
If DateNotified > = 0 Then
End
End If
I should have known not to edit code if you don't know what you're doing.
Again, I am a beginner.
Can you please let me know how I can prevent the Calendar of popping up when
there is already a date in the field when I open the form in edit mode?
 
Look back at the start of this thread. SOmeone already answered this
question.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Back
Top