Could someone look at my code and tell me why my “Me.TargetDate.Undo” won’t work?
First, let me say that the TargetDate field has an On-Click event that calls a module written by Allen Browne), which is shown below and works great.
=CalendarFor([TargetDate],"Select a date from the calendar ")
What happens is that the Me.TargetDate.Undo event always keeps the date selected in the calendar.
Based on something I read from Rual Guy on another issue, I’ve used the TargetDate_LostFocus routine to check for some additional data entry errors. I’ve tried moving the code in “Private Sub TargetDate_Exit(Cancel As Integer)” to the LostFocus, but it doesn’t make any difference to the Undo. I’ve also tried “I’ve tried “Private Sub TargetDate_Change(),Me.Undo…” but that doesn’t work either. :confused:
Private Sub TargetDate_Enter()
If Not IsNull(Me.TargetDate) Then
OldTarget = Me.TargetDate
End If
End Sub
Private Sub TargetDate_Exit(Cancel As Integer)
If Not IsNull(Me.TargetDate) Then
If DateDiff("d", Me.DateOpened, Me.TargetDate) < 0 Then
MsgBox "You have selected a date that is before…bla bla"
Me.TargetDate.Undo
Me.TargetDate.SetFocus
ElseIf DateDiff("d", Date, Me.TargetDate) < 0 Then
MsgBox "You have selected a date that is prior to today's date…bla bla"
Me.TargetDate.Undo
Me.TargetDate.SetFocus
ElseIf Weekday(Me.TargetDate) = 1 Or Weekday(Me.TargetDate) = 7 Then
MsgBox "You have selected a date that falls on a weekend..bla bla"
Me.TargetDate.Undo
Me.TargetDate.SetFocus
End If
End If
End Sub
Private Sub TargetDate_LostFocus()
If Me.TargetDate > OldTarget And Me.cboAssignToID <> OldAssignee Then
MsgBox "The target date can only be changed if …bla bla"
Me.TargetDate.Undo
Me.TargetDate.SetFocus
End If
End Sub
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
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)...
Within my main table / form I have six status drop down boxes and would like to record with a date and time ever time they are changed and save this data in a second table.
If I cant do this with the six drop downs, can I do it if any change has happened to the recorded.
I understand the problems that can be brought upon ones self by creating the table with lookup fields, But if the table was orginally designed with them and then the Field is then changed to a Text box instead of a Combo box will the inherent problems associated with the lookup within a table disappear?
Im a relative access newbie, and am updating an already created form. I want the user to be able to change the value in a field , then when they exit the field, for it to be greyed out, so that no more editing of the field is possible.
I know how to lock the field in design view, but I want the field to lock after the user has amended it. Is this possible?
The database contains the records of a collection of thousands of photographs and negatives.
One of the fields contains information on the subject matter of each pic and can sometimes be very long. The field was changed from text to memo so as to hold more characters but they appeared in one long string, which means a lot of scrolling to see the information. That has been changed back to text and we are adding a second or third record such as xxx-xxx-xxx cont1 xxx-xxx-xxx cont2 so as to get shorter strings. Is there a way to make the text wrap onto a second or third line automatically after a specific number of characters have been entered or can a carriage return be put in to force the text to a new line?
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...
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
' 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
Using a database 2010. I have a monthly import from a spreadsheet to one of my tables. Sometimes it has the same previous data from prior month or months that has not changed. I don't want to keep appending this data to my table if none of the fields have changed.
Is there a way to append data to table only if fields have changed in an append query? Ex. (Name, Address, PhoneNum, Rate) If all fields are the same; don't append. If one or more fields are changed; append.
I created a database with 10 tables and 8 relationships. Then, I learned about the Autonumber field type and decided that I wanted that to be the primary key of one of my existing tables, for a field that was already linked to 2 other tables. I had to delete the relationships and the original field to make the change, and Access said it had to delete an index, too. Now, Access won't allow me to re-establish those relationships.
I found that I had to change the fields in the other tables to match the Autonumber type and name of the original field, but now I am getting an error message stating, "Invalid field definition 'CustomerID' in definition of index or relationship. What does that mean? The field types and names are all the same.
On my form have a status field with about 7 options to choose from a combo box, i have these values set in another table. What i would like is for my other field, which is a date, to automatically change whenever the status field is changed. So i know how long ago the status field was set. So basically if i change the status to complete i want the date to then set the date and time now.
I have created a query that can used for tracking how many times a file is looked at or reviewed. My question is if I have a Field labled "Activity Date", can another field be created to add up how many time the date is changed in the "Activity Date" field. I am new to Access and have been learning on my own so any help would be greatly appreciated.
I have created a query that can used for tracking how many times a file is looked at or reviewed. My question is if I have a Field labled "Activity Date", can another field be created to add up how many time the date is changed in the "Activity Date" field. I am new to Access and have been learning on my own so any help would be greatly appreciated.
I Have made a change to a field in my tables. it was was based on ethnic background and originally i had just created the field but had not added in the options ( via adding it into the row sources).
So now the tables field have been updated but unfortunately on the form it has not updated into the dropdown i had created containing the options..
i have a form that shows payments (checks) that have been issued. sometimes those checks need to be voided and i want 2 fields (Updated By and Updated Date) to pop up when the payment distribution field is changed to a void status.
payment distribution: "I" for issued and "V" for void
i've gotten the On Change Event to work with VBA when the payment distribution changes from "I" to "V" and the 2 new fields pop up but if i exit the form and go back in to look at that record, the fields are gone. Is there a way to make the fields permanently if the payment is "V" on the form?
this is what i have so far for the On Change Event:
If [payment distribution] = "V" Then me.cmbo_UpdatedBy = True me.txt_UpdatedDate = True Else me.cmbo_UpdatedBy = False me.txt_UpdatedDate = False End If End Sub
I have a onclick tied to a label (for decoration purposes) that when clicked it launches VBA that essentially updates a form. All that part works except it will not recognize any changed value of the field I was last in?
Just to try to explain best as I can what happens.
- Form gets opened - I change field (quantity field) - I click the Label - It reverts to pre-existing value.
if I click off of the text field first then do the onclick - it recognizes just fine.
Hi all. I have three tables in my dbase related by user ID. All of the fields from the main table (client) are on the "Client" form. This table/form contains a number field called "Total Hours". There is a subform (Service Items) on the "Client" form which contains info from the "Service Items" table. The two are related by Customer ID. I can get a total of the number of hours spent on each client. It shows as a field in the footer of the "Service Item" form like so:=Sum([LaborHours]). Fine that part works.
What I dont know how to do is add another field to that footer that shows the result of the "Total Hours" from the Client table minus the Sum of Labor Hours from the Service Item table.
Basically a client would start with a set number of hours (Total Hours) and count down (minus the sum of LaborHours). How can I show the remaining hours?:confused:
It seemed like it would be easy but dang! Thanks for any help you can give...
I am trying to make a query using fields from multiple tables. I used the Expression builder to create it and it is a formula field where multiple table fields are involved. But whenever i run the query Access asks for a parameter value in a modal dialogue for the value of the fields. Is it because the field names has Square brackets around it? But access puts that automatically. How to make it work properly?
Order ID(Autonumber) Client ID(Text) Client Name(Short Text) Install Gross Rate (Currency) Install Discount Given in % (Number) Install Discount Given in GBP (Currency)
Then I designed a Query to calculate the Install Net Rate
Query
I selected Client ID Client Name Order ID
Expression: [Install Gross Rate]*(1-[Install Discount Given in %]/100)-[Install Discount Given in GBP]
I run the query, but only ONE order calculated correctly, rest of Orders returned blank row.
I am attempting to use a form field as the source for a query filter criteria. Everything works fine if I simply use an "if equal" filter condition. As soon as I try a "like" condition, nothing works.
I created a test table with just one column (fld1). The table contains three records with the following values: BRDODS, BRD, TLAODS.
The following hard coded query returns two records, as it should.
SELECT Table1.fld1 FROM Table1 WHERE (((Table1.fld1) Like 'BRD*'));
I also created a test form (Form1) with just one text field (Text0). My intent is to soft code a criteria value via the form field instead of hard coding the query, as above. When I populate the form field with BRDODS, the following soft coded query returns one record, as it should.
SELECT Table1.fld1 FROM Table1 WHERE (((Table1.fld1)=[Forms]![Form1]![Text0]));
When I enter LIKE "BRD*" in the form field, no records are returned. I should get two records, just like the hard coded query above.
I've tried all variations of the LIKE statement in the form field, but nothing works.
Is there a way to code something that will say do Undo All changes. I have a button called Exit without changes…and I would like to be able to undo everything that a user has just done on the form. Thanks.
Is there a way that I can make a button which will undo all the changes being made on a form (on multiple records). I have a continious form with a checkbox after each record and want to restore the 'old values' if necessary.
Thanks.
I know it's possible by record, but the tricky part is to do this on multiple records.