By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,505 Members | 1,511 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,505 IT Pros & Developers. It's quick & easy.

Calendar not working

P: 54
I several fields on a table set to date. On the form where users enter in the dates there automatically is a little calendar that shows up for them to select a date. This is nice because when entering many dates they can just click on the calendar instead of typing all of the dates. It only works the first time though. They enter information with these calendars and then click a submit button that takes them to a new record. This time when they click a date on the calendar it doesn't put the date into the box. They can still manually enter the date in though. Any ideas why this would be? Thanks.
Sep 6 '12 #1
Share this Question
Share on Google+
16 Replies


TheSmileyCoder
Expert Mod 100+
P: 2,321
What access version? Is it 2010 and built in calender control(Date picker), or is it a custom calender control?

Is the form in datasheet, single record view, or continuous or split? Is the form bound?
Sep 6 '12 #2

P: 54
Access version 2007. I guess it is the built in calender. It is just the one that appears at the side of a text box that is bound to a field on a table that accepts dates only. The form is just in the standard form view. The form is bound to the table with these fields that require dates.
Sep 6 '12 #3

TheSmileyCoder
Expert Mod 100+
P: 2,321
This sounds weird to me. Do you have any VBA code or macros running in the form? If so, please post it all here, for review.

So your saying that after the first record is added people can still click the date picker, and select a date, but the date does not get written into the control?
Sep 7 '12 #4

P: 54
This is all of the code for this form. The text boxes that are having this issue are "Date_Ordered" and "Delivery." Again it works the first time but not after that.
Expand|Select|Wrap|Line Numbers
  1. Private Sub BY_AfterUpdate()
  2. Me.Price_Unit.SetFocus
  3. End Sub
  4.  
  5. Private Sub BY_GotFocus()
  6. If IsNull(Me.Date) = True Then
  7. Me.BY.Locked = True
  8. Else: Me.BY.Locked = False
  9. End If
  10. End Sub
  11.  
  12. Private Sub Delete_Click()
  13. If IsNull(Me.finditem) = False Then
  14. Dim Msg, Style, Title, Response, MyString
  15.  
  16. Msg = "Are you sure you want to delete this order?" & vbNewLine & "You cannot undo this action."
  17. Style = vbYesNo
  18. Title = "Warning!"
  19.  
  20. Response = MsgBox(Msg, Style, Title, Help, Ctxt)
  21.  
  22. If Response = vbNo Then
  23. Exit Sub
  24. End If
  25. If Response = vbYes Then
  26. DoCmd.Hourglass True
  27. DoCmd.SetWarnings False
  28. RunCommand acCmdDeleteRecord
  29. DoCmd.SetWarnings True
  30.  
  31. Dim iCfg As Object
  32. Dim iMsg As Object
  33. Set iCfg = CreateObject("CDO.Configuration")
  34. Set iMsg = CreateObject("CDO.Message")
  35. With iCfg.Fields
  36. .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "exc2007.futuraind.com"
  37. .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  38. .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  39. .Update
  40. End With
  41.  
  42. 'Stop
  43. With iMsg
  44. .Configuration = iCfg
  45. .Subject = "Order Canceled"
  46. .to = Me.purchasesub!Notify
  47. .TextBody = "The order for " & Me.finditem & " submitted on " & Me.Date & " has been cancled by purchasing.  Please address any issues or concerns with purchasing."
  48. '.AddAttachment "FullPathToAttachment"
  49. .from = "Purchasing"
  50. .sender = "PurchasingNoReply@futuraind.com"
  51. .send
  52. End With
  53. Set iMsg = Nothing
  54. Set iCfg = Nothing
  55. Call MsgBox("Your order was processed successfully!", vbOKOnly, "Success!")
  56. DoCmd.Close acForm, "purchase chemicals"
  57. DoCmd.OpenForm "purchase chemicals"
  58. DoCmd.Hourglass False
  59. DoCmd.Close acForm, "purchase chemicals"
  60. DoCmd.OpenForm "purchase chemicals"
  61. End If
  62. ElseIf IsNull(Me.finditem) = True Then
  63. Call MsgBox("There is not an order to delete.")
  64. Exit Sub
  65. End If
  66. End Sub
  67.  
  68. Private Sub Complete_Click()
  69. If IsNull(Me.Date_Ordered) = True Then
  70. Call MsgBox("The Date Ordered is a required field.")
  71. Exit Sub
  72. ElseIf IsNull(Me.Date_Ordered) = False Then
  73. DoCmd.Hourglass True
  74. Dim iCfg As Object
  75. Dim iMsg As Object
  76. Set iCfg = CreateObject("CDO.Configuration")
  77. Set iMsg = CreateObject("CDO.Message")
  78. With iCfg.Fields
  79. .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "exc2007.futuraind.com"
  80. .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  81. .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  82. .Update
  83. End With
  84.  
  85. 'Stop
  86. With iMsg
  87. .Configuration = iCfg
  88. .Subject = "Order Completed On: " & DateValue(Now) & " at: " & TimeValue(Now)
  89. .to = Me.purchasesub!Notify
  90. .TextBody = "Date Requested: " & Me.Date & vbNewLine & "Item: " & Me.finditem & vbNewLine & "Units: " & Me.purchasesub!Units & vbNewLine & "Order Quantity: " & Me.purchasesub![Reorder Quantity] & vbNewLine & "Date Ordered: " & Me.Date_Ordered & vbNewLine & "Estimated Delivery Date: " & Me.Delivery & vbNewLine & "Purchase Order #: " & Me.PO & vbNewLine & "Purchased By: " & Me.BY & vbNewLine & "Price/Unit: " & Me.Price_Unit & vbNewLine & "Purchasing Comments: " & Me.Order_Comments
  91. '.AddAttachment "FullPathToAttachment"
  92. .from = "Purchasing"
  93. .sender = "PurchasingNoReply@futuraind.com"
  94. .send
  95. End With
  96. Set iMsg = Nothing
  97. Set iCfg = Nothing
  98. DoCmd.Close acForm, "purchase chemicals"
  99. DoCmd.OpenForm "purchase chemicals"
  100. DoCmd.Hourglass False
  101. End If
  102. End Sub
  103.  
  104. Private Sub Date_Ordered_AfterUpdate()
  105. Me.Delivery.SetFocus
  106. End Sub
  107.  
  108. Private Sub Date_Ordered_GotFocus()
  109. If IsNull(Me.Date) = True Then
  110. Me.Date_Ordered.Locked = True
  111. Else: Me.Date_Ordered.Locked = False
  112. End If
  113. End Sub
  114.  
  115. Private Sub Delivery_AfterUpdate()
  116. Me.PO.SetFocus
  117. End Sub
  118.  
  119. Private Sub Delivery_GotFocus()
  120. If IsNull(Me.Date) = True Then
  121. Me.Delivery.Locked = True
  122. Else: Me.Delivery.Locked = False
  123. End If
  124. End Sub
  125.  
  126. Private Sub edit_Click()
  127. DoCmd.OpenTable "ordering information"
  128. End Sub
  129.  
  130. Private Sub exit_Click()
  131. DoCmd.Close acForm, "purchase chemicals"
  132. DoCmd.OpenForm "order chemicals"
  133. End Sub
  134.  
  135. Private Sub finditem_GotFocus()
  136. Dim strFilter As String, strOldFilter As String
  137.     strOldFilter = Me.Filter
  138.     If Me!finditem > "" Then _
  139.         strFilter = strFilter & _
  140.                     " AND ([chemical] Like '" & _
  141.                     Me!finditem & "*')"
  142.     If strFilter > "" Then strFilter = Mid(strFilter, 6)
  143.     If strFilter <> strOldFilter Then
  144.         Me.Filter = strFilter
  145.         Me.FilterOn = (strFilter > "")
  146.     End If
  147. End Sub
  148.  
  149. Private Sub Form_Load()
  150. Dim strFEMaster As String
  151. Dim strFE As String
  152. Dim strMasterLocation As String
  153. Dim strFilePath As String
  154.  
  155. ' looks up the version of the front-end as listed in the backend
  156. strFEMaster = DLookup("fe_version_number", "tbl-version_fe_master")
  157.  
  158. ' looks up the version of the front-end on the front-end
  159. strFE = DLookup("fe_version_number", "tbl-fe_version")
  160.  
  161. ' looks up the location of the front-end master file
  162. strMasterLocation = DLookup("s_masterlocation", "tbl-version_master_location")
  163.  
  164. ' checks for the existence of an updating batch file and deletes it if it exists
  165.     strFilePath = CurrentProject.Path & "\UpdateDbFE.cmd"
  166.  
  167.     If Dir(strFilePath) <> "" Then
  168.         Dim fs As Object
  169.         Set fs = CreateObject("Scripting.FileSystemObject")
  170.         fs.DeleteFile (strFilePath)
  171.         Set fs = Nothing
  172.     End If
  173.  
  174.  
  175. ' if the current database opened is the master then it bypasses the check.
  176. If CurrentProject.Path = strMasterLocation Then
  177.  
  178.     Exit Sub
  179.  
  180. Else
  181.  
  182. ' if the version numbers do not match and it is not the master that is opened,
  183. ' the database will do the update process
  184.     If strFE <> strFEMaster Then
  185.         MsgBox "Your program is not the latest version." & vbCrLf & _
  186.         "The front-end needs to be updated.  The program will " & vbCrLf & _
  187.         "now close and then should reopen automatically.", vbCritical, "VERSION NEEDS UPDATING"
  188.  
  189.         ' sets the global variable for the path/name of the current database
  190.         g_strFilePath = CurrentProject.Path & "\" & CurrentProject.Name
  191.  
  192.         ' sets the global variable for the path/name of the database to copy
  193.         g_strCopyLocation = strMasterLocation
  194.  
  195.         ' calls the UpdateFrontEnd module
  196.  
  197.         UpdateFrontEnd
  198.  
  199.     End If
  200.  
  201. End If
  202.  
  203. End Sub
  204.  
  205. Private Sub Form_Open(Cancel As Integer)
  206. DoCmd.Maximize
  207. RunCommand acCmdRecordsGoToNew
  208. End Sub
  209.  
  210. Private Sub Order_Comments_AfterUpdate()
  211. Me.Date_Ordered.SetFocus
  212. End Sub
  213.  
  214. Private Sub Order_Comments_GotFocus()
  215. If IsNull(Me.Date) = True Then
  216. Me.Order_Comments.Locked = True
  217. Else: Me.Order_Comments.Locked = False
  218. End If
  219. End Sub
  220.  
  221. Private Sub PO_AfterUpdate()
  222. Me.BY.SetFocus
  223. End Sub
  224.  
  225. Private Sub PO_GotFocus()
  226. If IsNull(Me.Date) = True Then
  227. Me.PO.Locked = True
  228. Else: Me.PO.Locked = False
  229. End If
  230. End Sub
  231.  
  232. Private Sub Price_Unit_AfterUpdate()
  233. Me.Order_Comments.SetFocus
  234. End Sub
  235.  
  236. Private Sub Price_Unit_GotFocus()
  237. If IsNull(Me.Date) = True Then
  238. Me.Price_Unit.Locked = True
  239. Else: Me.Price_Unit.Locked = False
  240. End If
  241. End Sub
  242.  
  243. Private Sub refresh_Click()
  244. DoCmd.Close acForm, "purchase chemicals"
  245. DoCmd.OpenForm "purchase chemicals"
  246. DoCmd.SetWarnings False
  247. DoCmd.OpenQuery "delete"
  248. DoCmd.SetWarnings True
  249. End Sub
  250.  
Sep 7 '12 #5

zmbd
Expert Mod 5K+
P: 5,287
Becker,
I have not been able to recreate the issue with any of my test databases using v2010.

I'm guessing that you're using: http://msdn.microsoft.com/en-us/libr.../gg251104.aspx - is that correct?

Just double check the properties are set as indicated.

The other thing... temporarily comment out your afterupdate events for both of these controls as they seem to be just form movement and see what happens (I'm just poking at things here to see what screams in the dark). Ideally, you should have the tab-order for your form set to move from one control to the next for most things and use the set-focus only when needed for an unusual situation or to get information from the control (weird.. ms... what can I say?!)

-z
Sep 7 '12 #6

Rabbit
Expert Mod 10K+
P: 12,316
What is Me.Date? And why are a bunch of the controls getting locked if it's null?
Sep 7 '12 #7

P: 54
Z-Yes I am just using the built in date-picker. Settings are correct. I haven't changed anything with them. All I have done is made the field on the table require dates and the date-picker comes automatically. Yes my afterupdate events are just to move from one text box to another, like the tab controls. I am a newbie so I don't usually end up doing things in the most orthodox way I guess.

Rabbit-me.date is a box that contains that date that an order was submitted. The controls being locked is just my way of making sure that they do not enter information until they have actually selected an order to view.
Sep 7 '12 #8

zmbd
Expert Mod 5K+
P: 5,287
Another stab in the dark....

Change the locks to enabled=true/false... maybe the controls are still locked after the first go around?

-z
Sep 7 '12 #9

P: 54
They are not because I can type in the box. The calendar still shows up, but when I pick a date it does not go into the box.
Sep 7 '12 #10

zmbd
Expert Mod 5K+
P: 5,287
Becker,
I understand that; however, there maybe a bug in the datepicker so that it thinks that the control is still in the locked state.

On the test form I built (V2010) despite the control being in the locked state, I could select the text (couldn't change it) and the datepicker would also show - something I wouldn't have expected - that's ms for you.

ANYWAY... deep breath... Looking thru the developer's websites and a few other references I have access to - I have found a few other bug reports for the Datepicker where it hangs, doesn't let afterupdate fire, doesn't update a control, etc; however, nothing that matches what you are doing or I'd post the link. However, in each case I noted a common theme... the control was locked and then unlocked between losing and receiving focus and typically the control worked the first time but either failed the second time or at some random point. No-one seems to know why and I did not see this issue being reported as related to V2010, just V2007.

Being a scientist, chemist, we're trained to look for cause and effect, patterns... this caught my mind's eye as a pattern to test...

SO... I'm once again poking something sharp and pointy into the dark to see what screams... (ahh... October... the only month my morbid sense of humor gets to play };-) )

To test the hypothesis... try the form without locking any of the controls either by removing the locking entirely or by using the enabled property (ideally both).

On a personal note as an end user: I for one as a user get very annoyed at controls that appear like I should be able to enter data and they're locked. The enabled property (IMNSHO) is a better property when you need the information shown in that it allows the user to see the information and it is clearly for read-only.

That's the extent of the help I can offer at this point. I'll see if I can get a spider out looking for this for the other sites
-z
Sep 7 '12 #11

P: 54
Haha I tried removing the locks (so they are always unlocked) but it still didn't work.
Sep 7 '12 #12

P: 3
anything found to resolve this?? I have EXACTLY the same problem..
Jun 20 '14 #13

twinnyfo
Expert Mod 2.5K+
P: 3,063
Arno, et al,

I don't know if this will help at all, but it has worked for me--to assist users from accidentally adding an incorrect date format. It does not prevent from clicking into the text box, but it automatically unlocks the text box and brings up the calendar when the text box gets the focus, and then locks the text box when it loses focus.

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtDate_GotFocus()
  2.     Me.txtDate.Locked = False
  3.     DoCmd.RunCommand acCmdShowDatePicker
  4. End Sub
  5. Private Sub txtDate_LostFocus()
  6.     Me.txtDate.Locked = True
  7. End Sub
  8.  
Hope this hepps!
Jun 20 '14 #14

P: 3
that could be a workaround yes!

in the meantime i've found what causes this behaviour, not a solution though.
after filling in the date and saving the record, there comes a msgbox. The second time the datepickers stops working and if i do not show the msgbox, it keeps on working . So there must be something about the Dialog window of that msgbox that causes the Datepicker to stop working..
Jun 20 '14 #15

twinnyfo
Expert Mod 2.5K+
P: 3,063
I am certain that MS Access has a mind of its own, and is secretly working for the Borg!
Jun 20 '14 #16

P: 3
i guess... :p

anyhow, the behavior to the datepicker if called from withing VBA is the same. The only solution is to get rid of my msgboxes.. unbelievable
Jun 20 '14 #17

Post your reply

Sign in to post your reply or Sign up for a free account.