Solved

DateAdd Function

Posted on 2014-02-22
3
403 Views
Last Modified: 2014-02-22
Experts,
I am using the Date Add function to add hours to calculate an end time based on the start time entered on a form. I have hard coded a number (default is currently 2) as the increment so the function works, but what I really want to do is give the user an option to select a default increment that would be displayed in a control on a form. Is there any way to do this?
Thanks
This is the code that I am currently using
Private Sub cboMondayStart_AfterUpdate()
Me.cboMondayEnd = DateAdd("h", 2, Me.cboMondayStart)
End Sub

Open in new window

0
Comment
Question by:hbatt
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39879508
add a textbox "txtIncrement" to your form



Private Sub cboMondayStart_AfterUpdate()

if me.txtIncrement & ""<>"" then

Me.cboMondayEnd = DateAdd("h", me.txtIncrement, Me.cboMondayStart)

else
      msgbox "Enter increment!"
      me.txtIncrement.setFocus
      exit sub

end if


End Sub

or add a listbox/combobox with list of increment that the user can choose from


.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39879619
You might want to take a look at my article on command bars ( part 2).  In the attached database.  There is an example of using a shortcut menu to store values.

Sent from iphone
0
 

Author Closing Comment

by:hbatt
ID: 39879675
Thank you for your solution. I created a combo box with 1-12 values and it works perfectly. I also like that you set the focus to the cboIncrement control.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question