473,396 Members | 2,009 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,396 software developers and data experts.

Concat all Changes and Show in Save Confirmation Alert

How do i concat all changes made on a record and show it in the save confirmation alert?

** Edit** Was split from Customize save menu item in access data entry form
Jan 20 '10 #1

✓ answered by TheSmileyCoder

Well that would be very form specific, for instance do you have memo fields in your tables? Making a change string on a memo field could be rather ugly.

Also how do you want to display changes on combobox's? Should they show the value change, which will often be some foreign key? (atleast in my designs), or should they first column? or? or?

Well I've thrown this together for you. It only handles the combobox, since that the most complicated issue. You can add code to handle the textbox and checkbox case yourself I hope.
Expand|Select|Wrap|Line Numbers
  1. Public Function fncChanges(myForm As Form) As String
  2. Dim ctrl As Control
  3. Dim strChanges As String
  4. Dim intChanges As Integer
  5. Dim intI As Integer
  6.  
  7. For Each ctrl In myForm.Controls
  8.     If Not myForm.Dirty Then
  9.         strChanges = "No changes Made"
  10.         fncChanges = strChanges
  11.         Exit Function
  12.     End If
  13.  
  14.     'accombobox
  15.     If ctrl.ControlType = acComboBox Then
  16.         'Is it bound?
  17.         If (ctrl.ControlSource & "") <> "" Then
  18.             'Yes it is
  19.  
  20.             'Has anything changed?
  21.             If (ctrl.OldValue & "") <> (ctrl.Value & "") Then
  22.                 'Does it have more then 1 column?
  23.                 If ctrl.ColumnCount = 1 Then
  24.                     'It only has 1, probably a simple combobox
  25.                     strChanges = strChanges & "Field [" & ctrl.ControlSource & "] has changed from {" & ctrl.OldValue & "} to {" & ctrl.Value & "}" & vbNewLine
  26.                     intChanges = intChanges + 1
  27.                 Else
  28.                     'It has more then 1
  29.  
  30.                     'Are column widths specified?
  31.                         If (ctrl.ColumnWidths & "") <> "" Then
  32.                             'They are, retrieve first
  33.  
  34.                             For intI = 0 To InStr(1, ctrl.ColumnWidths, ";")
  35.                                 If Split(ctrl.ColumnWidths, ";")(intI) <> 0 Then
  36.                                     strChanges = strChanges & "Field [" & ctrl.ControlSource & "] has changed to {" & ctrl.Column(intI) & "}" & vbNewLine 'Note the ctrl.oldvalue wont do much good on a combobox
  37.                                     Exit For
  38.                                 End If
  39.                             Next
  40.  
  41.  
  42.                             Else
  43.                             'Haven't figured out have ot handle this case.
  44.                             strChanges = strChanges & "Bad case handle on Field [" & ctrl.ControlSource & "]" & vbNewLine
  45.                             intChanges = intChanges + 1
  46.                         End If
  47.  
  48.  
  49.                 End If
  50.             End If
  51.  
  52.  
  53.         End If
  54.     End If
  55. Next
  56.     fncChanges = strChanges
  57. End Function

I have made it so that if hte combobox doesn't have a controlsource (unbound) its ignored. Also the combobox will "record" the changed value of the first visible field (i.e. column width > 0)

10 1905
TheSmileyCoder
2,322 Expert Mod 2GB
There are several approaches to doing this. One could be be to make a loop running through each control, recording the changes, adding them to some string, and finally displaying the string. What I have sometimes done is to simply highlight the fields changed.


Expand|Select|Wrap|Line Numbers
  1. Private Sub HighlightChanges(boolTrue)
  2.     Dim ctrl As Control
  3.  
  4.     For Each ctrl In Me.Controls
  5.         If (ctrl.ControlType = acComboBox Or ctrl.ControlType = acTextBox) And Not ctrl.Name = "cmb_MainGroup" Then
  6.  
  7.             If boolTrue Then
  8.                     'True means highlight changes
  9.                     If IIf(IsNull(ctrl.Value), "NULLButCheckMeAnyway", ctrl.Value) <> IIf(IsNull(ctrl.OldValue), "NULLButCheckMeAnyway", ctrl.OldValue) Then
  10.                         'If it has changed from its originalvalue highligth it
  11.                         ctrl.BorderColor = vbRed
  12.                         ctrl.BorderWidth = 3
  13.                     End If
  14.                 Else
  15.                     'False means return to normal view
  16.                     ctrl.BorderColor = 0
  17.                     ctrl.BorderWidth = 1
  18.             End If
  19.  
  20.         End If
  21.     Next
  22. End Sub
Then I simply call this function in beforeUpdate before I ask the user, and I call it again in Form_Current with the false argument "restting" everything back to normal.
Jan 20 '10 #2
when u call highlightchanges in before update what do yu pass as argument,...boolean true?
Jan 20 '10 #3
i passed boolean true as argument and the highlight was not done
but the code gets executed where
# ctrl.BorderColor = vbRed
Jan 20 '10 #4
TheSmileyCoder
2,322 Expert Mod 2GB
What do you mean by executed?
And if you have made any changes to the code, please post the code here. Do you have unbound fields on the form?

Do you have calculated fields in the form?
Jan 20 '10 #5
ctrl.BorderColor = vbRed when this line of code gets excuted there is no colour chages on the form. i don have unbound or calculated values on the form.
Jan 20 '10 #6
TheSmileyCoder
2,322 Expert Mod 2GB
Im guessing you have border style set as transparent then :)
Jan 20 '10 #7
can u provide code for concatenating the changed values in string
Jan 20 '10 #8
TheSmileyCoder
2,322 Expert Mod 2GB
Well that would be very form specific, for instance do you have memo fields in your tables? Making a change string on a memo field could be rather ugly.

Also how do you want to display changes on combobox's? Should they show the value change, which will often be some foreign key? (atleast in my designs), or should they first column? or? or?

Well I've thrown this together for you. It only handles the combobox, since that the most complicated issue. You can add code to handle the textbox and checkbox case yourself I hope.
Expand|Select|Wrap|Line Numbers
  1. Public Function fncChanges(myForm As Form) As String
  2. Dim ctrl As Control
  3. Dim strChanges As String
  4. Dim intChanges As Integer
  5. Dim intI As Integer
  6.  
  7. For Each ctrl In myForm.Controls
  8.     If Not myForm.Dirty Then
  9.         strChanges = "No changes Made"
  10.         fncChanges = strChanges
  11.         Exit Function
  12.     End If
  13.  
  14.     'accombobox
  15.     If ctrl.ControlType = acComboBox Then
  16.         'Is it bound?
  17.         If (ctrl.ControlSource & "") <> "" Then
  18.             'Yes it is
  19.  
  20.             'Has anything changed?
  21.             If (ctrl.OldValue & "") <> (ctrl.Value & "") Then
  22.                 'Does it have more then 1 column?
  23.                 If ctrl.ColumnCount = 1 Then
  24.                     'It only has 1, probably a simple combobox
  25.                     strChanges = strChanges & "Field [" & ctrl.ControlSource & "] has changed from {" & ctrl.OldValue & "} to {" & ctrl.Value & "}" & vbNewLine
  26.                     intChanges = intChanges + 1
  27.                 Else
  28.                     'It has more then 1
  29.  
  30.                     'Are column widths specified?
  31.                         If (ctrl.ColumnWidths & "") <> "" Then
  32.                             'They are, retrieve first
  33.  
  34.                             For intI = 0 To InStr(1, ctrl.ColumnWidths, ";")
  35.                                 If Split(ctrl.ColumnWidths, ";")(intI) <> 0 Then
  36.                                     strChanges = strChanges & "Field [" & ctrl.ControlSource & "] has changed to {" & ctrl.Column(intI) & "}" & vbNewLine 'Note the ctrl.oldvalue wont do much good on a combobox
  37.                                     Exit For
  38.                                 End If
  39.                             Next
  40.  
  41.  
  42.                             Else
  43.                             'Haven't figured out have ot handle this case.
  44.                             strChanges = strChanges & "Bad case handle on Field [" & ctrl.ControlSource & "]" & vbNewLine
  45.                             intChanges = intChanges + 1
  46.                         End If
  47.  
  48.  
  49.                 End If
  50.             End If
  51.  
  52.  
  53.         End If
  54.     End If
  55. Next
  56.     fncChanges = strChanges
  57. End Function

I have made it so that if hte combobox doesn't have a controlsource (unbound) its ignored. Also the combobox will "record" the changed value of the first visible field (i.e. column width > 0)
Jan 20 '10 #9
thanks for the code smiley one ..
Jan 21 '10 #10
NeoPa
32,556 Expert Mod 16PB
I've had to split this into it's own separate thread as it was an entirely separate question. Please remember in future to keep questions in their own threads please.

You pleasant job now, Max, is to select whichever of TheSmileyOne's posts below you feel best captures the answer for this thread.
Jan 21 '10 #11

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

Similar topics

3
by: Nerses | last post by:
I have clustered IIS 5.0. It is working on a fail-over clustered model (Active-Passive), with one node as a preferred owner and the other only as a failover. I make the changes to IIS from one...
2
by: kelvin | last post by:
Hi, I'm having this problem and I can't seem to solve it. I've created a confirmation page. The page displays the form field data and has 2 links - OK (to continue) and Cancel (go back to...
6
by: Nedu N | last post by:
Hi, I want to have confirmation(Yes/No) on a button of the webform in which there are many validation controls. I want all the validation controls to be triggered first and then Yes/No...
1
by: Grey | last post by:
I can used the RegisterOnSubmitStatement to set the confirmation alert box, i.e. RegisterOnSubmitStatement("submit", "return confirm('Delete Page?');"). But this confirmation box prompted out from...
6
by: Frank Esser | last post by:
Hallo, I've got a project with about 10 pages. On each of them the user can do data changes (mostly datagrid interactions; the datagrids are bound to datasets). The user is able to jump to...
9
by: UJ | last post by:
I have a page where the user can make changes to some DB stuff. It's not saved until they hit the save button. I'd like to have it so that if they attempt to navigate somewhere else, I give them a...
0
by: neeraj | last post by:
Hi Everybody I have one problem in my asp.net web application. The problem is that I check the date validation in code behind; if user not gives the valid data and press save button then I fire...
3
by: beatdown | last post by:
Hi all, I have a set of Javascript functions that dinamically update the contents of a HTML <selectelement, depending on the value of another <select>. For easy understanding: I select a...
2
by: KC-Mass | last post by:
I have a form that is used to ID and then load Excel files into Access. I use labels on the form to record which file was last loaded. That was accomplished with a simple lblFileLoaded =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.