?
Solved

DateAdd Function

Posted on 2014-02-22
3
Medium Priority
?
409 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:Harry Batt
[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 2000 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 48

Expert Comment

by:Dale Fye
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:Harry Batt
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
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.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

765 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