Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pop-Up Calendar for Access Forms

Status
Not open for further replies.

PJname

MIS
Jun 15, 2004
73
US
Help!

I found some coding where I can include a pop-up calendar on my Access Forms for date fields. I have several forms that I would like to use this code to update one date or multiple dates depending on the form but I am having a problem where on some of the forms, the coding works wonderful, but on others, ugh!!!!!

for multiple dates ---

the coding I am using is the following:




change date field to a combo box

insert calendar using:
Calendar Control 8.0
visible = No

properties on date field -

on mouse down:

Option Compare Database
Dim cboOriginator As ComboBox
-----------------------------------------------------------
Private Sub Daily_date_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Note which combo box called the calendar
Set cboOriginator = Daily_date
' Unhide the calendar and give it the focus
ocxCalendar.Visible = True
ocxCalendar.SetFocus
' Match calendar date to existing date if present or today's date
If Not IsNull(cboOriginator) Then
ocxCalendar.Value = cboOriginator.Value
Else
ocxCalendar.Value = Date
End If
End Sub
------------------------------------------------------
Private Sub ocxCalendar_Click()
' Copy chosen date from calendar to originating combo box
cboOriginator.Value = ocxCalendar.Value
' Return the focus to the combo box and hide the calendar and
cboOriginator.SetFocus
ocxCalendar.Visible = False
' Empty the variable
Set cboOriginator = Nothing
End Sub

this form the coding works fine.

I use the same format for another form, but it doesn't work correctly. When I choose the date, it displays a small box with JULY and locks the form.


Any suggestions would be greatly appreciated............


 
Below I have pasted some code from a module I created. In this case I am selecting records, and appending them into a table based upon a date range. The user selects the date range from calendar controls on a form. While this is not exactly what you are trying to acheive, you can utilize the the calendar values as string variables in update queries.
Bear in mind that the code below are just the relevant fragments of a good deal more code... (unfortunately the lines are shifted a bit due to the tight spacing in this format. if you copy and paste it elsewhere, it should be more legible)

Code:
Dim InSQL1 As String    
Dim dateslct1 As String
Dim dateslct2 As String

dateslct1 = Forms![Form1]![ActiveXCtl0].Value
dateslct2 = Forms![Form1]![ActiveXCtl1].Value

DoCmd.Hourglass True
InSQL1 = "INSERT INTO BARGAIN_RCPTS " _
    + "( ISBN, PurchaseOrderNumber, TotalReceivedQty, ReceivedDate, WarehouseID ) " _
    + "SELECT Left([ISBN],10) AS Expr1, [331_Rcvg_Summed].[PO#], [331_Rcvg_Summed].Qty, " _
    + "[331_Rcvg_Summed].ReceiptDate, [331_Rcvg_Summed].WarehouseID " _
    + "FROM 331_Rcvg_Summed " _
    + "WHERE ((([331_Rcvg_Summed].ReceiptDate)>=#" + dateslct1 + "# And " _          + "([331_Rcvg_Summed].ReceiptDate)<=#" + dateslct2 + "#))"
DB.Execute InSQL1, dbFailOnError
DoCmd.Hourglass False
 
Thanks, Nevets

I was able to use the coding that I sent above and make a few adjustments and now my calendars are working correctly.

Thanks for taking time to respond to my question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top