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

Report Field Should Show “N/A” Based on Separate Field
Progress bar in in MS Access
SQL SELECT Query on related table
Assistance with combo box using lookup table - MS Access
MS access : how to add 1 row between 2 rows?
Access 2010 Error Accessing the system registry
How to edit subform based on joined tables in Access 2010
Textfield in Access 2003 query replaced by squares and asian symbols
Where do I put Access vba code to only fire when physically printing?
Loop through Access tables
Pass Parameter to Stored Procedure
Access 2007 VBA GoToRecord issue
MS Access 2012 Unresponsive to clicks when it has focus on citrix
Error 3155 (ODBC--insert on a linked table 'SAMPLE' failed)
I keep on getting an error 13 type mismatch error, How can I get it out?
MS Access Mark Duplicates in order of appearance

Categories

HOME
testing
yii2
cloud
debugging
netsuite
tizen
reserved
office365api
grep
elm
infragistics
gps
fsm
google-project-tango
angular-ui-bootstrap
webrequest
virtualization
u-sql
google-cloud-spanner
dtrace
iron-router
uitypeeditor
libtiff
saxon
introduction
opencover
hammerspoon
autosys
dynamic-featured-image
phpfox
tooltipster
ejabberd-module
bpel
frame
stormpath
protovis
xmlreader
language-concepts
atl
devextreme
occlusion
service-discovery
ansible-playbook
botbuilder
import-from-excel
btrace
jquery-validate
setter
forever
dtexec
mcafee
angular-strap
parallel-data-warehouse
ado.net-entity-data-model
mikroc
py2app
pagedlist
sigabrt
superstack
suffix-tree
javax.sound.midi
teamcity-8.0
marching-cubes
spidermonkey
content-length
android-listview
map-projections
deis
javax.mail
nsmutabledictionary
fscommand
offloading
clicktag
c3
coldbox
asp.net-dynamic-data
relocation
applescript-objc
jubula
doskey
imdbpy
html5-notifications
gridfs
web2py-modules
opcache
dotnetnuke-5
browser-detection
gil
gnustep
qt-jambi
subgurim-maps
winbugs14
imac
fluent-interface
blitz++
suppress
asp.net-profiles
substrings
photoshop-cs4
text-coloring
gacutil
genealogy
windows-live-messenger
3gp
lzh

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