Solved

An update macro for Microsoft Access

Posted on 2016-09-17
12
38 Views
Last Modified: 2016-11-02
Hi, Experts

I have been trying to create a macro to update a colum for sometime now but i wont work :(

Here is what i want to do.

i have a field call Deliverystatus with two choice "Not delivered" and "delivered"
I have another field call Delivered date

I want to create a macro so that when someone change Deliverytstatus to "delivered"
The Delivered Date gets populate but the todays date.

Please some point me into right direction :D

Thanks in advance
0
Comment
Question by:Arthit84
12 Comments
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 41803094
Access is limited and do not have the trigger feature built-in, hence we can't execute a DML command by detecting update of a field.

>>I want to create a macro so that when someone change Deliverytstatus to "delivered"
The Delivered Date gets populate but the todays date.
we need to know how the end user update the DeliveryStatus? if it's via a Form, we need to execute an update sql statement after the change is completed.
0
 

Author Comment

by:Arthit84
ID: 41803098
Thansk for answering Ryan

yes it is via Form

i am not an expert in access so please tell me a little about the update SQL statement
0
 
LVL 19

Assisted Solution

by:Eric Sherman
Eric Sherman earned 250 total points (awarded by participants)
ID: 41803131
Use the AfterUpdate of your control on the Form as shown below ...

Private Sub ComboDeliveryStatus_AfterUpdate()

If Me.ComboDeliveryStatus = "Delivered"  Then
     Me.Delivery_Date = Now()
Else
     Me.Delivery_Date = Null
End If

Me.Dirty = False

End Sub


ET
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 19

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 250 total points (awarded by participants)
ID: 41803134
actually Access does have "triggers". They are called Data Macros. It is easier, however, to use VBA and respond to a form or control event.
0
 

Author Comment

by:Arthit84
ID: 41803145
thanks experts i will test this later tonite.
0
 
LVL 19
ID: 41803147
you're welcome :)

Now() gives you date and time.  If you only want date, use
Date()

Open in new window

... and change the reference to Me.Delivered_Date (says Me.Delivery_Date)
0
 

Author Comment

by:Arthit84
ID: 41803152
any of the experts that have worked with access Web app in sharepoint?
0
 
LVL 19

Accepted Solution

by:
crystal (strive4peace) - Microsoft MVP, Access earned 250 total points (awarded by participants)
ID: 41803154
0
 

Author Comment

by:Arthit84
ID: 41803940
Thanks for the links i watched the video its really great and fun to know that Access is very powerful.
I have not have the time to test it, i will test and report back.
Best regards
0
 
LVL 19
ID: 41804014
you're welcome ~ glad you like it
0
 
LVL 19
ID: 41833337
poster said he would come back but didn't ... guess he is busy working on his app!
0
 

Author Comment

by:Arthit84
ID: 41871092
Hello i apologize that i have not been online, i though that i already close this thread at sepetember i quess i must have done something wrong.
The app is working great and i am really learn alot from the website from the video.
Now i am taking some course in Lynda and CBTnuggets on Access :D

Thanks you again and sorry that i missed this thread
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

776 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