473,386 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Record Change

67
Hi everyone

When i open frmSales i have disabled the save button. What i want is if any field on the form is changed the save button is enabled. I can't use OnKey Press as the user might tab through the fields, so it needs to be code. I tried the forms On Data Change but it didn't work.

Any ideas are appreciated.

Regards

Wayne
Feb 13 '09 #1
8 2929
missinglinq
3,532 Expert 2GB
This will Enable the Save button when data is entered/edited:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Dirty(Cancel As Integer)
  2.  cmdSave.Enabled = True
  3. End Sub
This will reset Enabled to False when moving to a new record
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.  cmdSave.Enabled = False
  3. End Sub
Just replace cmdSave with the actual name of your button.

Linq ;0)>
Feb 13 '09 #2
NeoPa
32,556 Expert Mod 16PB
As data is saved automatically when navigating to a different record, I don't see what use there would be for a Save CommandButton.

Were you aware of this?

Is there any code behind the button other than a simple Save?
Feb 13 '09 #3
Wayneyh
67
Thanks again missinglinq

Much appreciated

Wayne
Feb 13 '09 #4
Wayneyh
67
Yes there is code behind it.

When they Click save it changes a checkbox to true to and adds the date it was saved. This tells the user that the record needs to be re-printed.
Expand|Select|Wrap|Line Numbers
  1. Private Sub btnSave_Click()
  2.  
  3.     DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  4.     MsgBox "Customer Details for" & " " & Me.Company & " " & "have been saved to the database."
  5.     Me.Changed.Value = True
  6.     Me.BtnClose.Enabled = True
  7.     If Me.Changed.Value = True Then
  8.     Me.ChangedDate = Date
  9.     Me.Printed.Value = False
  10.     Me.Invoice_PrintedDate = ""
  11.     End If
  12.  
  13. End Sub
Feb 13 '09 #5
NeoPa
32,556 Expert Mod 16PB
In that case I suggest you consider ensuring that the record is not saved simply by navigating away from it, as is the normal way of working for a form. Alternatively, use the form's BeforeUpdate() event handler to trigger the same code that is used in your btnSave_Click() procedure.

The way to do this might be :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.   Call CommonCode()
  3. End Sub
  4.  
  5. Private Sub btnSave_Click()
  6.   Call CommonCode()
  7. End Sub
  8.  
  9. Private Sub CommonCode()
  10.   Blah
  11.   Blah
  12.   Blah
  13. End Sub
PS. Please notice the edit comment added to some of your posts about using [ CODE ] tags. This is a requirement. As a full member you would be expected to know the rules by now.
Feb 13 '09 #6
NeoPa
32,556 Expert Mod 16PB
@NeoPa
I suppose some clarification on this wouldn't hurt either.
Try something like the following :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.   Call MsgBox("Remember to use the Save button (various insulting expletives)!")
  3.   Cancel = True
  4. End Sub
Feb 13 '09 #7
Wayneyh
67
Hi NeoPa

Thanks for your advice, I will try them out and I apologise for not biding by the rules of the forum.

Wayne
Feb 13 '09 #8
NeoPa
32,556 Expert Mod 16PB
No worries Wayne.

I hope the code proves helpful.
Feb 13 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: BT3 | last post by:
I am trying to replace a single record in a flat file. The file is relatively small and no need for database. I open the file, and save the ftell() value in a variable. I read a record using...
5
by: Xiphias | last post by:
Hi, Can someone help me to create a drop box where I can also add new records? Here is the problem: I m working on a form with a drop box. When I select a '"name" in the drop box the form...
4
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button wizard (result: DoCmd.GoToRecord , , acNext). I...
6
by: DebbieG | last post by:
I have created a database for a client and was told that it was to be a one-user database. Well, you know the next statement ... now they want 3 people to be able to use the database. (FYI, I...
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
4
by: James P. | last post by:
Hello there, I have a bound-form using Navigator so that the user can move back and forth to update record in the form. Every time a record was modified and the user clicks the Navigator to...
5
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example...
22
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
7
by: Neil | last post by:
Was working in A2003 and noticed that the Save Record item on the Records menu was not available when the record was not dirty. In A2000, Save Record was always available. (This is a problem for me...
19
by: emanning | last post by:
Using Access 2003 and using a form that's mostly bound. I need a way to tell if user-1 is on the record when user-2 tries to open the same record, w/o waiting for the user-1 to save the record...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.