Link to home
Start Free TrialLog in
Avatar of get-ADuser -F ($_.Name -eq "Todd")
get-ADuser -F ($_.Name -eq "Todd")Flag for United States of America

asked on

I have a pop up calendar but need to manually enter as well

I made activex calendar control that assigns into some text boxes and it work great.  The deal is some users like to enter the txtboxes manually.  Is there a way to do this with the code I have here.  Right now I have a variable that passes back and forth.

Option Compare Database
Option Explicit
Dim txtOriginator As TextBox

Private Sub BegDate_Click()
Set txtOriginator = BegDate
Me.Calendar6.Visible = True
Me.Calendar6.SetFocus
If Not IsNull(txtOriginator) Then
   Calendar6.Value = txtOriginator.Value
Else
   Calendar6.Value = Date
End If
End Sub

Private Sub Calendar6_Click()
txtOriginator.Value = Calendar6.Value
txtOriginator.SetFocus
Calendar6.Visible = False
Set txtOriginator = Nothing

End Sub


Private Sub EndDate_Click()
Set txtOriginator = EndDate
Me.Calendar6.Visible = True
Me.Calendar6.SetFocus
If Not IsNull(txtOriginator) Then
   Calendar6.Value = txtOriginator.Value
Else
   Calendar6.Value = Date
End If
End Sub


Thanks in advance

Net
Avatar of jefftwilley
jefftwilley
Flag of United States of America image

If the underlying recordsource has the start and end date fields, then create a separate set of textboxes specifically for manual entry and bind them to those fields in the recordsource. This would bypass your calendars.
J
Avatar of get-ADuser -F ($_.Name -eq "Todd")

ASKER

The form generates a query that creates a report.  the txtboxes that are populated are [BegDate] & [EndDate]  here is my query.

SELECT ORDERS.CabShipDate, ORDERS.AOP, Builders.BuildersName, ORDERS.Subdivision, ORDERS.[Instl Boxes], ORDERS.SellingPrice, ORDERS!SideMark & "" & ORDERS!Parcel & "-" & ORDERS!Lot AS SideMark, ORDERS.BuildersId
FROM Builders RIGHT JOIN ORDERS ON Builders.CustomerID = ORDERS.BuildersId
WHERE (((ORDERS.CabShipDate) Between [Forms]![Monthly Revenue]![BegDate] And [Forms]![Monthly Revenue]![EndDate]) AND ((ORDERS.BuildersId) Like Nz([Forms]![Monthly Revenue]![cboBldr],"*")))
ORDER BY ORDERS.CabShipDate;

The query creates between the dates selected on Form Monthly Revenue.

Thanks

Net
When you go to this form, are there values already assigned to your text boxes? Are they visible? It looks like you actually have to click a button to make your calendars visible....I guess I'm confused. If you've got the textboxes, can't you simply type into them? The query doesn't care whether the textboxes are populated using the calendar control or not...as long as there are dates in them.
Yeah, I know.  And you have a point.  I'm in the process of modifying it now.  The event should be "double click" on the txtboxes.  I built the calendar after someone asked if there was a way to have one.  It originally was text entry text boxes.  I'm trying to make bells and whistles.  I know that I could probably use DTPicker, but I work for a big company and the I.S. dept is "somewhat slow and leary" on adding anything new to our network.  That activeX control has to be downloaded and registered on each PC.  I was trying just to use the control already installed.

Thanks

Net
so are you looking for a way to manually enter the date on the calendar control itself?
The form is basically, 2 txtboxes.  It says enter dates.   A lable at the bottom says, double click date box for calendar.  Then it has a button for preview and a button for print.

But, If you try to manually enter a date into the BegDate or the EndDate, it enters today's date.  No matter what you type, it comes back as the date on the calendar control.   What I need it to do is to allow a person to type any date (if they don't want to use the calendar).  If they want to use the calendar, they double click and then use the control to fill the txtboxes.  Again, it's different user suggestions.  I'm just trying to be accomodating to all.  

Net
Are the BegDate or EndDate bound to a table? or unbound? Sounds like one of two things could change that might get you what you want. First, set date fields using the Form_Open event instead of what sounds like the control source being set to =Date().

Second...make sure there's no other events firing when the textboxes get the focus.

You can also set a default value for the text boxes =Date(). that will initially set them to today's date, but allow them to change it.

Check their control sources...I think you'll find they are the culprit
Unbound text with no control source listed.  No events firing on "got focus".  I'm not sure what you mean on "setting date field on the Form_Open event."
I think my problem is the variable txtOriginator, so that I only needed to use one Calendar Control, I wonder if I just make a duplicate calendar, clear the Dim and Set and make the Calendar6_Click() event = BegDate and another calendar control = EndDate . I just thought there was an easier way.  What do you think?

Net
Something is setting the value of the textboxes outside of the code you pasted in originally. What you pasted were 3 events. each required a "Click" or a double "Click". But you say the behavior of the textboxes is such that even if you enter a date into them and tab out for example, it resets the date. so there's something else changing the date. Are there any other events in the form module for your form?
I screwed up JeffWilley,  I had this in my code. I wanted to format the boxes without using an imput mask. It works now.  But could you tell me how to format so if they put 12/1,  it would come out 12/1/2006?  Input masks I hate!

code:
Private Sub BegDate_AfterUpdate()
Me.BegDate = Format(Date, "mm/dd/yyyy")
End Sub

and this

Private Sub EndDate_AfterUpdate()
Me.EndDate = Format(Date, "mm/dd/yyyy")
End Sub

I wanted to format the boxes without using an imput mask.  Could


sorry, jefftwilley,

That's the second time I've butchered your name.  :)

Net
ASKER CERTIFIED SOLUTION
Avatar of jefftwilley
jefftwilley
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help and patience

Net