Modules & VBA :: Preventing Undo Changes To Data In A Form

Mar 10, 2014

I'm using the following code to ask the user whether to save changes to the data, don't save changes or Cancel the close and continue editing. I'm closing the form using the 'X' only.

Code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim UserResp As Integer
UserResp = MsgBox("Record(s) have been added or changed." & vbCrLf & "Save the changes?", vbYesNoCancel)
Select Case UserResp

[Code] ....

The problem I'm having is when I press the 'Cancel' button in the message box. When I press 'Cancel' the form remains open (bPreventClose=True) which is what I want. But the changes to the data get undone even though I don't have Me.Undo in that case.

First, what's causing the undo?
Second, how do I prevent the data from undoing when I press 'Cancel.'

I went to add a record earlier and selected 'Cancel' because I wanted to change one small item. I lost all the data I had put in and had to start over.

View Replies


ADVERTISEMENT

Modules & VBA :: Hide Undo Button Until Data Entry On Form?

Mar 8, 2015

I have an Undo button : [btnUndo] and would like it hidden until someone starts to enter data, where it will become visible...

what code would I use? and where would

Code:
me.btnUndo.visible = true

be triggered?

View 3 Replies View Related

Modules & VBA :: Undo Method When Using Form And Subform / Lookup Tables

Feb 3, 2015

How come its so hard to create an undo method when using a form and subform, lookup tables and tiered selections in combo boxes?

View 3 Replies View Related

Preventing Opening A Form Unless Data Is Entered? And Some Other Q's.

Oct 29, 2006

Hello again,

I have three questions this time 'round:

1. I'm in need of some way of preventing a user from opening form B unless he has entered information in form A.

Right now it is possible to open form B without entering data in form A (form A being the date/time info and form B being the case technical info) due to which a record is created for clientnr 0 (which should be a non existing client). Querying for clientnr 0 from time to time and deleting those records is easy enough, but who knows what kind of relevant data could be stored accidentally in a record that doesn't belong there.

This happens by the way, even though referential integrity is enforced throughout the dbase. Maybe I should say, because of that. I want to keep it that way of course to prevent orphans roaming around. But having orphans for clientnr. 0 is also not a good idea.


2. What is the wiser thing to do: keep all information concerning one case for one client (date/time info per case, techinfo per case, maybe even products sold info per case, payment info per case) in one table and have the data needed for each thing entered in seperate forms, or have all data split up into seperate tables like I have now. One for clients, one for dates and times, one for the technical info for that case etc.... ?

It is starting to seem a bit ehrm... useless to have all that data for one case floating around seperate tables. I don't know... it seems so much more complex (having to create multiple relations, multiple PK's per table etc.).

Where do I draw the line? For example the image attached (relationship2.jpg): now I have one PK in the table holding the clients (clientnr), two PK's in the table holding the case date/time info (clientnr and casenumberdatetimeinfo), three PK's in the table holding the techinfo (clientnr, casenumberdatetimeinfo and casetechinfonr). And what's next? Four PK's in the table holding the sold productsinfo? Five PK's in the table holding the invoice info? And what about the relations between those tables? Right now I can still comprehend.... but when I start thinking ahead, I'm starting to get dizzy. So some advice on this would really be highly appreciated.

3. Which build up of the relations between the tables in the dbase is better? The one in relationship.jpg or the one in relationship2.jpg?

View 8 Replies View Related

Modules & VBA :: Beforeupdate Event Undo Change To A Combo Box?

Oct 7, 2013

I'm working on a bit of code that before a combobox is changed checks with the user to confirm that they want the change to go ahead, if yes a recorded is added to a table

This all work fine apart from if no is selected - I am trying to get the combobox to undo the change however when you select no the msgbox pops up fine but the combobox does not undo

Can't see where I'm going wrong I thought undo worked for comboboxes

Code:
' Displays a message box with the yes and no options.
Response = MsgBox(prompt:="Do you wish to change the status of this Job? 'Yes' or 'No'.", Buttons:=vbYesNo)
' If Yes button selected
If Response = vbYes Then

[Code] .....

View 3 Replies View Related

Preventing Data Deletion

Dec 5, 2007

I have developed a database in Access which has user permissions implemented. These are set so that only Full Data Users have permission to delete information.

However, it has come to my attention that users can get around this by creating a query and then deleting records displayed in its results. I can't understand why this is possible, because the permissions should prevent this.

Can anyone help?

Thanks,

Gary

View 1 Replies View Related

Preventing Of Adding Data To Combobox

Feb 13, 2008

In C# this combo box is calling "DropDownList".
How to make in in Access?

View 3 Replies View Related

Modules & VBA :: Preventing Probable Duplicate Records

Jun 21, 2013

I have a table called tblCompanies in which I have a field called CompanyName that is indexed set to "no duplicates". However, I want access to be able to pick out probable duplicates instead of only exact duplicates.

So, for example, if "Butter Fingers" is entered and "Butterfingers" is already in the database, I want access to prevent the new record from being created.

The code I found on MS Developer's reference only prevents exact duplicates which seems pointless since this can be done just as effectively on the table level using an index.

Anyway, here is the code:

Private Sub CompanyName_BeforeUpdate(Cancel As Integer)
If (Not IsNull(DLookup("[CompanyName]", _
"tblCompanies", "[CompanyName] ='" _
& Me!CompanyName & "'"))) Then
MsgBox "Company has already been entered in the database."
Cancel = True
Me!CompanyName.Undo
End If
End Sub

Can it somehow be modified to do what I want it to do?

View 8 Replies View Related

Preventing Duplicate Data From Multiple Fields

Mar 4, 2008

Hello All,

I'm trying to limit the data entered into a specifc field, but also the data must be unique with respect to other fields.

i.e.
Two fields: System A & System B.
Data entered into System A, can not be entered into System B.

Anyway to prevent this from recurring?
Would I use a validation rule?

Thanks in advance

View 4 Replies View Related

Queries :: Preventing Data From Being Changed After Running A Query

Feb 28, 2014

I have some queries that pull data from one table and other queries that pull data from two related tables. In both cases, how do I prevent the data from being changed after the queries results are displayed? I know I could make a form and lock each field so it couldn't be changed, but I was hoping to avoid having to do that.

View 6 Replies View Related

Forms :: Preventing Data To Change When Text Box Value Is Changed

Apr 24, 2013

A form displays information on a construction site in various text boxes. I want to enable the user to change this information but not until a save button is pressed.

Now I have the problem that as soon as I change the value of a text box, the data in the database is updated.

Is there a way to prevent these updates but still get the text fields to be linked to the attributes of a table?

View 2 Replies View Related

Undo Won't Undo Last Function.

May 4, 2006

I have a Memo box where the user puts comments and then I have a check box that if check automatically puts a specific phrase on the first line of the Memo box (before any other text currently in the box). What I am trying to do is have it so that if the "check box" is UN-checked it will remove the line that it just added to the Memo box. I have been able to get it to undo everything in the Memo box, but what I really need is for it to just undo the last line of text that was enterd when the user checked the box.

Example:

Memo Box:
This is the line that the checkbox just added when the checkbox is set to "True"
This is the test data the user has already put in the box...
==================

User now UN-checks the checkbox (I want the Memo box to read.. see below) Thereby deleting the line "This is the line that the checkbox just added when the checkbox is set to "True""

Memo Box:
This is the test data the user has already put in the box...

How can I accomplish this?

View 1 Replies View Related

Undo, Won't Undo - Do I Understand Right?

Nov 14, 2006

Hi, I have found the answer to most of my problem, thanks to previous posts.
I am using the Undo command on a Date field. However it seems that my code is maybe not staying on the event to action the undo.

After it runs the Focus goes to the next field Me.LeaveDays and the value is automatically entered, unless I comment back in the Goto's in which case the value will be zero.

I want to be able to Undo the EndDate (and preferable the StartDate, and Setfocus to StartDate) EndDate will do if not possible.

Don't want to Undo the whole form, although that could be a last resort.

My code is in the before_update event, image posted (ignore faded fields, not visible/needed in final solution)
Private Sub EndDate_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_EndDate_BeforeUpdate

Dim intLeaveLeftAL As Integer
Dim intLeaveLeftSL As Integer
Dim intLeaveDays As Integer
Dim dtNullDate As Date
Dim varNullField As Variant

intLeaveLeftAL = Nz(Forms!frmAddLeaveRecords.fsubLeaveAgTots.Form![DailyALInc] - (Forms!frmAddLeaveRecords.fsubLeaveAgTots.Form![ALDays] - Forms!frmAddLeaveRecords.fsubLeaveAgTots.Form![ACDays]), 0)
intLeaveLeftSL = Nz(10 - Forms!frmAddLeaveRecords.fsubLeaveAgTots.Form![SLDays], 0)

' Use the WorkingDays function to calc the number of Leave Days
' set LeaveDays and requery the form
intLeaveDays = WorkingDays(Me.StartDate, Me.EndDate)

If Me.LCode = "LC41" Then ' Sick Leave

Select Case intLeaveDays
Case Is > intLeaveLeftSL
MsgBox "Employee does not have enough Leave" & vbCrLf & "to take as Sick Leave.", vbCritical + vbOKOnly + vbDefaultButton1, "Entry in Error"
varErrorCondition = True
Me.EndDate.Undo
GoTo Exit_EndDate_BeforeUpdate
Case Else:
End Select

ElseIf Me.LCode = "LC11" Or Me.LCode = "LC13c" Then ' Annual or C/Fwd Leave

Select Case intLeaveDays
Case Is > intLeaveLeftAL
MsgBox "Employee does not have enough Leave" & vbCrLf & "to take as Annual Leave.", vbCritical + vbOKOnly + vbDefaultButton1, "Entry in Error"
varErrorCondition = True
Me.EndDate.Undo
GoTo Exit_EndDate_BeforeUpdate
Case Else:
End Select
End If

Me.LeaveDays = intLeaveDays
Me.LeaveDays.Requery
varErrorCondition = False

Exit_EndDate_BeforeUpdate:
Exit Sub

Err_EndDate_BeforeUpdate:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_EndDate_BeforeUpdate

End Sub
The ifs and cases work fine, just like to send the User back a few steps
appreciated :) :)

View 9 Replies View Related

Modules & VBA :: Preventing Duplicates On Multiple Fields (Numeric And Text)

Oct 15, 2013

How to prevent duplicates on the combination of two fields - text & numeric?

I'm currently using the code below that warns users when the combination of two fields have already been used. (Combination of the TWO fields has to always be unique so if used again will warn the user)

Works well when both fields are numeric but fails when the JobDetails field is changed to text in the main table (tblPPMPLanner)

Code:
Option Compare Database
Option Explicit
Private Function IsDuplicateRecord() As Boolean
On Error Resume Next
Dim PreviousRecordID As Long
IsDuplicateRecord = False

[Code] ....

The field that should be a text field is called "JobDetails"

View 5 Replies View Related

General :: Undo Changes Made To A Form?

Jul 23, 2012

It has really been awhile I posted in this forum
I have a form purchase order details, that I used to enter quantity of items purchased. I found out that I can't delete quantities entered on the form. It appears to delete, but on checking the quantity in the inventory, it was not deleted. The vba code in my quantity section of the page is this

Quantity_AfterUpdate()
Dim IT As InventoryTransaction
If Me![Quantity] = 0 Then
RemoveCurrentLineItem
End If
AddPurchase Me![Purchase Order ID], Me![Item ID], Me![Quantity], NewInventoryID
End Sub

View 1 Replies View Related

Forms :: Undo All Changes To Form And Subform?

Sep 25, 2013

I have some forms where I can cancel my input. However this works only on the current record. When I implement a subform this does not work anymore. Because access auto saves when focus is set to the subform.

I don't wan't to use unbound forms. What I would like to do is when I press EDIT that a snapshot or something is taken of the current values. So I can set them back.

I can use variables for the main form, but I don't know how to save the values of the records of the subform.

Or does the possibility exist to use transactions?

I just want to be able to undo all changes regardless of the subforms.

View 3 Replies View Related

Forms :: Undo Only One Field On A Form?

Jul 14, 2014

I need to program vba to "Undo" only one field on a form, not the entire form. The user enters a number of fields and then tabs to a text field which allows them to enter an 8 digit code. If this code matched one already in the database, I have a message box telling them of the match and offering to either clear the entry or to allow them to go back and edit what they have entered. The 2nd part of this works fine, but I can't figure out how to just clear the text box without clearing the entire form. (the form is bound to a table)

I have tried DoCmd.RunCommand acCmdUndo which clears the entire form.

Me.TextBox.undo does nothing at all.

(a search found several websites that say use Me!TextBox.undo, but that doesn't pass the complier)...

View 14 Replies View Related

Identify Errors Preventing Data From Importing From Access To Excel

May 1, 2014

I have been consistently getting an error almost every month when I try to load some data that has been input into access, then I have it linked to an excel sheet so that whenever I refresh, the access data imports into excel and updates my pivots, charts, etc.

When my data entry ppl enter data, sometime they forget to enter a code, or something, and when they forget to enter that, it creates some kind of error in the query. The query still runs in access, but shows something similar to " #ERROR#" in the field IF I ever do find it in the access query. The issue is that I cant filter to find that error. I literally have to scan and scroll through thousands of lines of data to try and find this error. When I try to refresh the data in excel, the following error message pops up;

"Data could not be retrieved from the database. Check the database server or contact your database administrator. Make Sure the external database is available, and then try the operation again."

In past months I can usually find the #ERROR# by scrolling through access and finding it. Some months I have EXTREME trouble finding the error. It can take hours out of my work day. Is there any way to more easily identify which line these errors are in rather than scrolling through thousands of lines of data? Is there a way to still export the data to excel with the errors still in them?

View 3 Replies View Related

Forms :: Why To Undo Edits After Changed Records In A Form

Jul 22, 2013

I thought "Undo" was only available while in the current record.Here were my steps:

1 - Loaded form that shows 1 record per form page.
2 - Edited a record
3 - Moved to another record with status bar nav arrow
4 - Verified my edit was in the underlying table
5 - Moved back to the original record, again using status bar nav arrow
6 - Clicked my "undo" control and the original data appeared in the form
7 - Moved to another record
8 - Verified my original data was now back in the underlying table

My undo control has this vba on click:

Code:
DoCmd.RunCommand acCmdUndo

View 1 Replies View Related

Preventing Form From Resizing

Sep 7, 2005

Hi
I have a Switch Board and when I click to view a report on it the report automatically opens in maximize view, this is what I want. What I dont want is when I close the report for the Switch Board form to be maximized as well

How would I be able to prevent this??
Cheers
bikeboardsurf :rolleyes:

View 2 Replies View Related

Preventing Duplicates In A Form

May 28, 2007

Hi all,
I've got a database with a members table and an events table and a participation table which is like an 'intermediary table' which just has fields for MemberID_fk and EventID_fk.

The form at the moment has a combo box for Members and a combo box for events. This works well but the problem with it is that there is no safeguards to prevent a member from joining the same event many time.

Ideally i'd like for the combo box of events to be updated once the member's been selected to only include events the member has not signed up for.

If anyone's got any suggestions i'd love to hear them. The only constraint i have is that this has to be prevented when it is entered in the form.

Cheers,
Joe

View 3 Replies View Related

Preventing User From Restoring Form

Jul 11, 2006

Hi

Hoping someone can help me here. I have a form which is maximised on startup which also has the min/max and close button disabled. What i'd like to do is also prevent the user from restoring the form to ie. click the restore button which then makes the form smaller as i'd like the form to permanently remain maximised.

I'm not sure if this is possible, but if not is there a way to size the form to fit the height and width of the screen as if it was maximised regardless of the screen resolution the user is using.

Any help would be appreciated.

View 3 Replies View Related

Undo Changes In Subform(in Datasheet View) From A Cick Event Of A Button In Main Form

Aug 5, 2005

Hi everyone!!
This is my first thread in this forum..Hope to get best from this site ..well i m facing a problem..i have a main form and a subform (which is in datasheet view) . Now i have a button called "close_form" in main form on whose click event i have writen this code :

Private Sub close_form_Click()
On Error Resume Next
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
Me.Controls.Item("fees sub").SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.Close
End Sub

1. If i run this form directly from Access and there are no changes i do in the form and click this button then it gets hang after showing error "run time error 2046 ; the command or action undo is not available now " "press End or Debug or help"

2. As i have created a Custom menu, if i run this form from that menu then it does not show any error. But it runs fine for the first time but nothing happens on clicking this button the second time i open the same form ( in same session).
What to do ?? Please help ..
shikha

View 2 Replies View Related

Preventing A Form Close /save If Not Valid

Jan 26, 2008

I have validation logic that runs to test whether certain fields are inputted properly etc on my form. I call these methods in the Before_Update of each form. But How do i actually STOP the update from happening? OR how do i stop the form from being closed?
Right now, I just give all these warnings but the save still happens!

View 5 Replies View Related

General :: Preventing Changes And Additions Except Through Appropriate Form / Table?

Nov 9, 2012

While I was trying to test one of my forms (which was NOT working and I had to totally redesign it), I somehow created a bunch of stores in my Store Information table...some with no names, some with the first letter of an existing store, and there was even a duplicate of the store which is creating a problem now because some products exist in Store 1A and others exist in Store 1B.

I've created a query to identify the wayward products and am changing those. I'll delete that store then.

My issue is...can I set it so that the ONLY place a new store can be created is in the Store Information Input form? That if someone makes a typo when entering products, it doesn't create a new store?

Access 2010

View 2 Replies View Related

Custom Save Button On Form Preventing Subform

Jun 21, 2005

I have a main form and a sub form. Tbhidden and tbpropersave are the text boxes that govern the update procedure. The main form has two text box that i use to prevent the user from modifying the information on the main form without clicking my custom save button. the problem is that the subform should be completed after the information on the main form has been filled in. The Update code i have refuses to allow me to complete the subform without first clicking the save button on the main form. Here is the code. I wana be able to fill in info in the main form, then the sub form then click save. The sub form is a table which relates to the main form table Many to One.

Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Form_BeforeUpdate

Me.tbhidden.SetFocus

If Me.tbPropersave.Value = "No" Then
Beep
MsgBox "Please Save This Record!" & vbCrLf & vbLf & "You can not advance to another record until you either 'Save' the changes made to this record or 'Undo' your changes.", vbExclamation, "Save Required"
DoCmd.CancelEvent
Exit Sub
End If

Exit_Form_BeforeUpdate:
Exit Sub

Err_Form_BeforeUpdate:
If Err = 3020 Then 'Update or CancelUpdate without AddNew or Edit
Exit Sub
Else
MsgBox Err.Number, Err.Description
Resume Exit_Form_BeforeUpdate
End If



Please HELP


End Sub

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved