Microsoft
Software
Hardware
Network
Question : How to get back original value of a combo box
Help! I am stuck... I am using MS Access 2003
In a form, I have an APPROVAL field that is a combo box created from tbl_Status (SELECT DISTINCT tbl_Status.ApprovalID, tbl_Status.Approval FROM tbl_Status ORDER BY tbl_Status.Approval; ) with properties (column count =2 and Bound Column =1) --
tbl_status
ApprovalID Approval
1 Empty
3 Pending
4 Rejected
6 Approved
7 Applied
Here is the problem, there are only 2 users (Mr. A and Mr. B) can change the statuses of APPROVAL field to anything, and only those 2 users can change any statuses to "Approved" -- Besides those 2 users, anyone can change other statuses besides "Approved" -- If Other users will change the status to "Approved" -- For example, the original Approval status was "Pending", a user wanted to change, from "Pending" to "Approved" and a user can't change the "Approved" status to any other statuses -- Once it "Approved" - it set and only Mr A or Mr. B can change the "Approved" status to other statuses -- There will be a message prompted "Sorry! You do not have the PERMISSION to change the status to APPROVED or APPROVED to any other statuses -- Please contact either Mr. A or Mr. B" and the Approval value must roll back to its original "Pending" value instead stayed as "Approved"
I did create 2 Text Boxes: txt_Approval_ID and txt_Approval to store it's original values when the form opened -- here is my simple codes
Private Sub Approval_AfterUpdate()
Dim ctlCombo As Control
' Return Control object pointing to a combo box.
Set ctlCombo = Me!Approval
If Me.Approval.Column(1) = "Approved" And Forms!frm_Login!txt_Approv
al = "Yes" Then
Me.txt_Signature.Visible = True
Me.Signature_Date = date()
Else
If Me.Approval.Column(1) = "Approved" And Forms!frm_Login!txt_Approv
al = "No" Then
MsgBox "Sorry! You do not have the PERMISSION to change the status to APPROVED -- Please contact either Mr. A or Mr. B"
Me!Approval.Column(0) = Me!txt_Approval_ID
Me!Approval.Column(1) = Me!txt_Approval
' Requery source of data for list box.
ctlCombo.Requery
Else
End If
End If
End Sub
What should I do to make the Approval combo box to be able to roll back its other original statuses besides "Approved"?
Thanks much
Answer : How to get back original value of a combo box
OldValue is available in VBA.
from VBA window, Help type OldValue
and you will see an example
Random Solutions
T-SQL Count Issue
Help File Format for program
Runtime error 6 "Over flow" in excel when select the whole sheet content by Ctrl + A
Read/Write textbox of another application
Handling Access Null value message when running against Oracle table
Wait For Shell Command to Finish
Blank document opens when opening another word document.
Server 2008 Backup
Generate a Graph/Chart from a Crosstab Query - Can it be done dynamically?
Page numbering to start from 3rd page.