Solved

DateAdd Function

Posted on 2014-02-22
3
405 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

730 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