If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
Easy Time Entry on a form?? Help.
I'm back. The "date and time picker" form itself is good, but I can't figure
out how to use it to get the date and time back to the original field/form. Here's what I have: a form and subforms with many different date/time fields. Each of those fields are of date/time type and store both the date and time in the same field. The need is simple - I don't want anything fancy, but I have a lot of date/time fields and it would help my users to be able to use a GUI to enter the date and time rather than enter it in manually a specific way. I want to: 1) doubleclick any of the date fields, 2) have it open the calendar to the date within the field or to today's date if null, 3) the user selects the date and time in the form and clicks the Select button to close, 4) have the selected date and time appear in the original field and eventually saved to the record. It seems like I need to use an external function/module, but I just can't figure out how to pass the values and get the selected date/time back into the correct field. As it is, we probably have to concatenate the two fields from the calendar together to get the date and time in one field. Can anyone help? There are so many different calendars and instructions out there and it's hard to pull just what I need from all of them. I don't use VB regularly enough to remember the syntax to open forms and pass values correctly. Thank you! "Van T. Dinh" wrote: zipped file is on its way. -- HTH Van T. Dinh MVP (Access) "Tech Geek 1234" wrote in message ... Hello! My situation is almost exactly like what JeffC described. I have several fields that require both date and time to be entered, and it would be nice if I could provide a calendar tool to make data entry easier. Would you be able to forward me that zip file you sent Jeff? Or point me to a website or two that have date and time pickers? techgeek1234 at hotmail.com Thank you! |
#12
|
|||
|
|||
Easy Time Entry on a form?? Help.
Here the code I use to call the Form "frmDTPicker" for a Control
[txtDateFrom]: ******** Private Sub cmdFromDateCal_Click() On Error GoTo cmdFromDateCal_Click_Err With Me If (IsDate(.txtDateFrom)) Then ' The first part (before ";" is the date/time to set the initital value ' and the second part is the Caption to be used for the "frmDTPicker" DoCmd.OpenForm gDTPICKERFORM, , , , , acDialog, _ Format(.txtDateFrom, "yyyy\-mm\-dd\ hh\:nn\:ss") & _ ";Select Start Date/Time" Else DoCmd.OpenForm gDTPICKERFORM, , , , , acDialog, _ ";Select Start Date/Time" End If ' Back from the acDialog Calendar If (CurrentProject.AllForms(gDTPICKERFORM).IsLoaded = True) Then .txtDateFrom = Forms(gDTPICKERFORM).acxCalendar + _ Forms(gDTPICKERFORM).acxTimePicker DoCmd.Close acForm, gDTPICKERFORM, acSaveNo Call txtDateFrom_AfterUpdate End If End With cmdFromDateCal_Click_Exit: On Error Resume Next Exit Sub cmdFromDateCal_Click_Err: Select Case Err.Number Case 0 Case Else MsgBox "Error " & Err.Number & ": " & Err.Description & vbCrLf & vbCrLf & _ "(Programmer's note: Form_frmProductionEntry_ByDay.cmdFromDateCal_Click )", _ vbOKOnly + vbCritical, "Run-time Error!" End Select Resume cmdFromDateCal_Click_Exit End Sub ******** Watch out for line-wrapping due to posting ... -- HTH Van T. Dinh MVP (Access) "Tech Geek 1234" wrote in message news I'm back. The "date and time picker" form itself is good, but I can't figure out how to use it to get the date and time back to the original field/form. Here's what I have: a form and subforms with many different date/time fields. Each of those fields are of date/time type and store both the date and time in the same field. The need is simple - I don't want anything fancy, but I have a lot of date/time fields and it would help my users to be able to use a GUI to enter the date and time rather than enter it in manually a specific way. I want to: 1) doubleclick any of the date fields, 2) have it open the calendar to the date within the field or to today's date if null, 3) the user selects the date and time in the form and clicks the Select button to close, 4) have the selected date and time appear in the original field and eventually saved to the record. It seems like I need to use an external function/module, but I just can't figure out how to pass the values and get the selected date/time back into the correct field. As it is, we probably have to concatenate the two fields from the calendar together to get the date and time in one field. Can anyone help? There are so many different calendars and instructions out there and it's hard to pull just what I need from all of them. I don't use VB regularly enough to remember the syntax to open forms and pass values correctly. Thank you! |
#13
|
|||
|
|||
Easy Time Entry on a form?? Help.
Thank you for the info (and reminder about wrapping in posts). I've put the
code in and changed the necessary names to match my names. I am getting an error msg "Error 2494: The action or method requires a Form Name argument." When I comment out the "on error" statement, the vb debugger points to the first If paragraph - not that that helps pinpoint the problem! I have some thoughts and the code below if you would be able to continue helping me! :-) 1) Am I missing a form name or something? I noticed the name you put in the posting and the form name within the code are different, one begins with "g". I just put in the form name as I have it in the Access database window. Do I need to do something different, like declare a form object, or specify it or something? 2) Also, I noticed that the txtDateFrom data is being formatted; do I need this step? If so, do I need to move the "yyyy" to the end of the date as that's how I have it in the field to begin with? 3) You Call txtDateFrom_AfterUpdate; do I need this or can I comment it out? I don't know what's in that procedure. I have it commented out for now. 4) Also - I can open the calendar form itself fine and use the calendar and. But just in case, do I need to be running a version of Access or have the control installed on my machine? (I am running 2003 - but my company probably has the version defaulted to 2000 or something to keep us all using the same version of databases.) Code Replacements -- My form name is "frmCalendar" and replaces your "gDTPickerForm". -- My date field is called "txtTrainingRel" and replaces your "txtDateFrom". -- I intend to use the DblClick event to initiate the calendar, but for now I have created a command button to keep it as similar to yours as possible. My button is "cmdGetDate" to replace your "cmdFromDateCal". Code: Private Sub cmdGetDate_Click() On Error GoTo cmdFromDateCal_Click_Err With Me If (IsDate(.txtTrainingRel)) Then ' The first part (before ";" is the date/time to set the initial value ' and the second part is the Caption to be used for the "frmDTPicker" DoCmd.OpenForm frmCalendar, , , , , acDialog, _ Format(.txtTrainingRel, "yyyy\-mm\-dd\ hh\:nn\:ss") & _ ";Select Start Date/Time" Else DoCmd.OpenForm frmCalendar, , , , , acDialog, _ ";Select Start Date/Time" End If ' Back from the acDialog Calendar If (CurrentProject.AllForms(frmCalendar).IsLoaded = True) Then .txtTrainingRel = Forms(frmCalendar).acxCalendar + _ Forms(frmCalendar).acxTimePicker DoCmd.Close acForm, frmCalendar, acSaveNo 'Call txtDateFrom_AfterUpdate End If End With cmdFromDateCal_Click_Exit: On Error Resume Next Exit Sub cmdFromDateCal_Click_Err: Select Case Err.Number Case 0 Case Else MsgBox "Error " & Err.Number & ": " & Err.Description & vbCrLf & vbCrLf & _ "(Programmer's note: Form_frmProductionEntry_ByDay.cmdFromDateCal_Click )", _ vbOKOnly + vbCritical, "Run-time Error!" End Select Resume cmdFromDateCal_Click_Exit End Sub Thank you for your help! "Van T. Dinh" wrote: Here the code I use to call the Form "frmDTPicker" for a Control [txtDateFrom]: ******** Private Sub cmdFromDateCal_Click() On Error GoTo cmdFromDateCal_Click_Err With Me If (IsDate(.txtDateFrom)) Then ' The first part (before ";" is the date/time to set the initital value ' and the second part is the Caption to be used for the "frmDTPicker" DoCmd.OpenForm gDTPICKERFORM, , , , , acDialog, _ Format(.txtDateFrom, "yyyy\-mm\-dd\ hh\:nn\:ss") & _ ";Select Start Date/Time" Else DoCmd.OpenForm gDTPICKERFORM, , , , , acDialog, _ ";Select Start Date/Time" End If ' Back from the acDialog Calendar If (CurrentProject.AllForms(gDTPICKERFORM).IsLoaded = True) Then .txtDateFrom = Forms(gDTPICKERFORM).acxCalendar + _ Forms(gDTPICKERFORM).acxTimePicker DoCmd.Close acForm, gDTPICKERFORM, acSaveNo Call txtDateFrom_AfterUpdate End If End With cmdFromDateCal_Click_Exit: On Error Resume Next Exit Sub cmdFromDateCal_Click_Err: Select Case Err.Number Case 0 Case Else MsgBox "Error " & Err.Number & ": " & Err.Description & vbCrLf & vbCrLf & _ "(Programmer's note: Form_frmProductionEntry_ByDay.cmdFromDateCal_Click )", _ vbOKOnly + vbCritical, "Run-time Error!" End Select Resume cmdFromDateCal_Click_Exit End Sub ******** Watch out for line-wrapping due to posting ... -- HTH Van T. Dinh MVP (Access) "Tech Geek 1234" wrote in message news I'm back. The "date and time picker" form itself is good, but I can't figure out how to use it to get the date and time back to the original field/form. Here's what I have: a form and subforms with many different date/time fields. Each of those fields are of date/time type and store both the date and time in the same field. The need is simple - I don't want anything fancy, but I have a lot of date/time fields and it would help my users to be able to use a GUI to enter the date and time rather than enter it in manually a specific way. I want to: 1) doubleclick any of the date fields, 2) have it open the calendar to the date within the field or to today's date if null, 3) the user selects the date and time in the form and clicks the Select button to close, 4) have the selected date and time appear in the original field and eventually saved to the record. It seems like I need to use an external function/module, but I just can't figure out how to pass the values and get the selected date/time back into the correct field. As it is, we probably have to concatenate the two fields from the calendar together to get the date and time in one field. Can anyone help? There are so many different calendars and instructions out there and it's hard to pull just what I need from all of them. I don't use VB regularly enough to remember the syntax to open forms and pass values correctly. Thank you! |
#14
|
|||
|
|||
Easy Time Entry on a form?? Help.
See comments in line.
-- HTH Van T. Dinh MVP (Access) "Tech Geek 1234" wrote in message ... Thank you for the info (and reminder about wrapping in posts). I've put the code in and changed the necessary names to match my names. I am getting an error msg "Error 2494: The action or method requires a Form Name argument." When I comment out the "on error" statement, the vb debugger points to the first If paragraph - not that that helps pinpoint the problem! I have some thoughts and the code below if you would be able to continue helping me! :-) 1) Am I missing a form name or something? I noticed the name you put in the posting and the form name within the code are different, one begins with "g". I just put in the form name as I have it in the Access database window. Do I need to do something different, like declare a form object, or specify it or something? Yes, I use the [frmDTPicker] at numerous places so I use a global constant declared in a standard module. This way, if for some reason, I need to change the name of the Form [frmDTPicker], I only need to change in one place in code. 2) Also, I noticed that the txtDateFrom data is being formatted; do I need this step? If so, do I need to move the "yyyy" to the end of the date as that's how I have it in the field to begin with? Leave the Format alone. That is how the [frmDTPicker] expects it. If you want to change, you need to modify the code in the [frmDTPicker] also. 3) You Call txtDateFrom_AfterUpdate; do I need this or can I comment it out? I don't know what's in that procedure. I have it commented out for now. Yes. It is for the processing that I need to do if the date value is changed. You can comment it out if you don't need "automatic" processing as soon as the date value is changed. 4) Also - I can open the calendar form itself fine and use the calendar and. But just in case, do I need to be running a version of Access or have the control installed on my machine? (I am running 2003 - but my company probably has the version defaulted to 2000 or something to keep us all using the same version of databases.) Access 2000 also has the Calendar Control but different version. You need to change the References of the database to the correct version of the Calendar Control. Code Replacements -- My form name is "frmCalendar" and replaces your "gDTPickerForm". -- My date field is called "txtTrainingRel" and replaces your "txtDateFrom". -- I intend to use the DblClick event to initiate the calendar, but for now I have created a command button to keep it as similar to yours as possible. My button is "cmdGetDate" to replace your "cmdFromDateCal". Code: Private Sub cmdGetDate_Click() On Error GoTo cmdFromDateCal_Click_Err With Me If (IsDate(.txtTrainingRel)) Then ' The first part (before ";" is the date/time to set the initial value ' and the second part is the Caption to be used for the "frmDTPicker" DoCmd.OpenForm frmCalendar, , , , , acDialog, _ Format(.txtTrainingRel, "yyyy\-mm\-dd\ hh\:nn\:ss") & _ ";Select Start Date/Time" Else DoCmd.OpenForm frmCalendar, , , , , acDialog, _ ";Select Start Date/Time" End If ' Back from the acDialog Calendar If (CurrentProject.AllForms(frmCalendar).IsLoaded = True) Then .txtTrainingRel = Forms(frmCalendar).acxCalendar + _ Forms(frmCalendar).acxTimePicker DoCmd.Close acForm, frmCalendar, acSaveNo 'Call txtDateFrom_AfterUpdate End If End With cmdFromDateCal_Click_Exit: On Error Resume Next Exit Sub cmdFromDateCal_Click_Err: Select Case Err.Number Case 0 Case Else MsgBox "Error " & Err.Number & ": " & Err.Description & vbCrLf & vbCrLf & _ "(Programmer's note: Form_frmProductionEntry_ByDay.cmdFromDateCal_Click )", _ vbOKOnly + vbCritical, "Run-time Error!" End Select Resume cmdFromDateCal_Click_Exit End Sub Thank you for your help! |
#15
|
|||
|
|||
Easy Time Entry on a form?? Help.
Thanks for your comments. I'll work with the form name, maybe try that
global constant idea. Hopefully that will solve the error. As for changing the reference to the control, I'm not sure exactly what that means. I just know that the form works when I open it by itself, I just need to obtain the selected date/time from it. Thanks for all your help. I'll give it another stab and see if I can get it working. Otherwise, they'll just have to type in the date! "Van T. Dinh" wrote: See comments in line. -- HTH Van T. Dinh MVP (Access) "Tech Geek 1234" wrote in message ... Thank you for the info (and reminder about wrapping in posts). I've put the code in and changed the necessary names to match my names. I am getting an error msg "Error 2494: The action or method requires a Form Name argument." When I comment out the "on error" statement, the vb debugger points to the first If paragraph - not that that helps pinpoint the problem! I have some thoughts and the code below if you would be able to continue helping me! :-) 1) Am I missing a form name or something? I noticed the name you put in the posting and the form name within the code are different, one begins with "g". I just put in the form name as I have it in the Access database window. Do I need to do something different, like declare a form object, or specify it or something? Yes, I use the [frmDTPicker] at numerous places so I use a global constant declared in a standard module. This way, if for some reason, I need to change the name of the Form [frmDTPicker], I only need to change in one place in code. 2) Also, I noticed that the txtDateFrom data is being formatted; do I need this step? If so, do I need to move the "yyyy" to the end of the date as that's how I have it in the field to begin with? Leave the Format alone. That is how the [frmDTPicker] expects it. If you want to change, you need to modify the code in the [frmDTPicker] also. 3) You Call txtDateFrom_AfterUpdate; do I need this or can I comment it out? I don't know what's in that procedure. I have it commented out for now. Yes. It is for the processing that I need to do if the date value is changed. You can comment it out if you don't need "automatic" processing as soon as the date value is changed. 4) Also - I can open the calendar form itself fine and use the calendar and. But just in case, do I need to be running a version of Access or have the control installed on my machine? (I am running 2003 - but my company probably has the version defaulted to 2000 or something to keep us all using the same version of databases.) Access 2000 also has the Calendar Control but different version. You need to change the References of the database to the correct version of the Calendar Control. Code Replacements -- My form name is "frmCalendar" and replaces your "gDTPickerForm". -- My date field is called "txtTrainingRel" and replaces your "txtDateFrom". -- I intend to use the DblClick event to initiate the calendar, but for now I have created a command button to keep it as similar to yours as possible. My button is "cmdGetDate" to replace your "cmdFromDateCal". Code: Private Sub cmdGetDate_Click() On Error GoTo cmdFromDateCal_Click_Err With Me If (IsDate(.txtTrainingRel)) Then ' The first part (before ";" is the date/time to set the initial value ' and the second part is the Caption to be used for the "frmDTPicker" DoCmd.OpenForm frmCalendar, , , , , acDialog, _ Format(.txtTrainingRel, "yyyy\-mm\-dd\ hh\:nn\:ss") & _ ";Select Start Date/Time" Else DoCmd.OpenForm frmCalendar, , , , , acDialog, _ ";Select Start Date/Time" End If ' Back from the acDialog Calendar If (CurrentProject.AllForms(frmCalendar).IsLoaded = True) Then .txtTrainingRel = Forms(frmCalendar).acxCalendar + _ Forms(frmCalendar).acxTimePicker DoCmd.Close acForm, frmCalendar, acSaveNo 'Call txtDateFrom_AfterUpdate End If End With cmdFromDateCal_Click_Exit: On Error Resume Next Exit Sub cmdFromDateCal_Click_Err: Select Case Err.Number Case 0 Case Else MsgBox "Error " & Err.Number & ": " & Err.Description & vbCrLf & vbCrLf & _ "(Programmer's note: Form_frmProductionEntry_ByDay.cmdFromDateCal_Click )", _ vbOKOnly + vbCritical, "Run-time Error!" End Select Resume cmdFromDateCal_Click_Exit End Sub Thank you for your help! |
#16
|
|||
|
|||
Easy Time Entry on a form?? Help.
|
|
Thread Tools | |
Display Modes | |
|
|