ms-access


Updating Table with Interval visits based on other table's start and end date


I designed an MS Access app for our maintenance department to control the visit schedule.
I have 2 main tables:
Project data (Project name, no of visits, contract start date, end date, amount, etc...)
PPM (no of visit, scheduled date of the visit and visit type)
Currently we are adding the data on the new project in the first table, and then we are updating the second table with the dates Manual. e.g. if I have a project start on 01/01/2017 and it will end on 31/12/2017 and we have to conduct 4 visits (Quarterly). So we are updating the 2nd table as the following:
Visit no 1 02/01/2017 Quarterly Visit
Visit no 2 04/01/2017 Quarterly Visit
Visit no 3 07/01/2017 Quarterly Visit
Visit no 2 10/01/2017 Quarterly Visit
This to be able to get a schedule report.
The question is: can I have a way to fill the 2nd table (PPM) automatically based on start date and end date and no of visits of each contract?
Yes, requires VBA code. Something like this:
Sub CreatePPM(dteStart As Date, dteEnd As Date, strType As String)
Dim x As Integer, dteVisit As Date
dteVisit = dteStart
Select Case strType
Case "Quarterly"
'code here
Case "Daily"
While dteVisit <= dteEnd
CurrentDb.Execute "INSERT INTO PPM(VisitNo, VisitDate, VisitType) Values(" & x & ", #" & dteVisit & "#, 'Daily')"
dteVisit = dteVisit + 1
Wend
End Select
End Sub
Modify code as required to handle different visit types. I have to say coding for the Quarterly type does seem to be challenging.
Then figure out what event to put the code into. Perhaps a button click or AfterUpdate event of Project data entry form. Will probably need additional code to make sure records are not entered multiple times.
When you develop code and have specific issue, post question.

Related Links

Autopopulate textbox on combobox update in MS Access
Combine code to shorten it
Is it possible to print a query through a form in MS Access?
Where is the Form/Report `Menu` event (that relates to OnMenu) defined in Access?
Access VBA DLookup: Syntax error (missing operator) in query expression
MS Access - Speed Issue
MS Access 2016 - Updating Multiple Tables
Concatenated numbers stuck in scientific notation MS Access
ms access for each field
in access how to draw tables on Report and then export it on word
Automatically adding ID number from different table to new entries?
Access VBA Outlook MAPI- Prevent Record Update if email is not sent
data type mismatch error in criteria expression-ms access
Access Main Form 'Enter Parameter Value'
How to get a combobox2 to display records only relating to the selection made in combobox1?
Ms Access: Running an update query

Categories

HOME
compiler-construction
single-sign-on
smarty
mean-stack
maven-3
sharepoint-designer
baqend
ravendb
mvvmcross
pivotal-cloud-foundry
acquia
task
vaadin7
progressive-web-apps
oracle-coherence
zapier
tokenize
css-animations
accessor
buck
jspm
large-file-upload
webkitspeechrecognition
gitignore
gsoap
microsoft-chart-controls
bluestacks
socialengine
phonegap
kendo-ui-grid
stringtemplate
automake
theano.scan
az-application-insights
email-templates
slick-3.0
hibernate-tools
upstart
jedis
worksheet
winscp-net
fancybox-2
tropo
svmlight
magma
font-size
nested-sets
time-and-attendance
home-directory
dstu2-fhir
file-writing
intrusion-detection
phishing
contact-list
angstrom-linux
hover-over
bgp
msys
cyclomatic-complexity
graph-drawing
bigbluebutton
java.util.concurrent
zend-route
openexr
xceed-datagrid
kgdb
openlaszlo
jsctypes
tws
flash-builder4.5
dataadapter
html-editor
angularjs-controller
mhtml
newtonscript
objective-c-2.0
buildr
asyncfileupload
gnu-prolog
qt-jambi
blackberry-playbook
xmemcached
ecl
winbugs14
pyinotify
sortable-tables
w3wp
multiple-languages
uiq3

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App