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. - Public Function fncChanges(myForm As Form) As String
-
Dim ctrl As Control
-
Dim strChanges As String
-
Dim intChanges As Integer
-
Dim intI As Integer
-
-
For Each ctrl In myForm.Controls
-
If Not myForm.Dirty Then
-
strChanges = "No changes Made"
-
fncChanges = strChanges
-
Exit Function
-
End If
-
-
'accombobox
-
If ctrl.ControlType = acComboBox Then
-
'Is it bound?
-
If (ctrl.ControlSource & "") <> "" Then
-
'Yes it is
-
-
'Has anything changed?
-
If (ctrl.OldValue & "") <> (ctrl.Value & "") Then
-
'Does it have more then 1 column?
-
If ctrl.ColumnCount = 1 Then
-
'It only has 1, probably a simple combobox
-
strChanges = strChanges & "Field [" & ctrl.ControlSource & "] has changed from {" & ctrl.OldValue & "} to {" & ctrl.Value & "}" & vbNewLine
-
intChanges = intChanges + 1
-
Else
-
'It has more then 1
-
-
'Are column widths specified?
-
If (ctrl.ColumnWidths & "") <> "" Then
-
'They are, retrieve first
-
-
For intI = 0 To InStr(1, ctrl.ColumnWidths, ";")
-
If Split(ctrl.ColumnWidths, ";")(intI) <> 0 Then
-
strChanges = strChanges & "Field [" & ctrl.ControlSource & "] has changed to {" & ctrl.Column(intI) & "}" & vbNewLine 'Note the ctrl.oldvalue wont do much good on a combobox
-
Exit For
-
End If
-
Next
-
-
-
Else
-
'Haven't figured out have ot handle this case.
-
strChanges = strChanges & "Bad case handle on Field [" & ctrl.ControlSource & "]" & vbNewLine
-
intChanges = intChanges + 1
-
End If
-
-
-
End If
-
End If
-
-
-
End If
-
End If
-
Next
-
fncChanges = strChanges
-
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
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. - Private Sub HighlightChanges(boolTrue)
-
Dim ctrl As Control
-
-
For Each ctrl In Me.Controls
-
If (ctrl.ControlType = acComboBox Or ctrl.ControlType = acTextBox) And Not ctrl.Name = "cmb_MainGroup" Then
-
-
If boolTrue Then
-
'True means highlight changes
-
If IIf(IsNull(ctrl.Value), "NULLButCheckMeAnyway", ctrl.Value) <> IIf(IsNull(ctrl.OldValue), "NULLButCheckMeAnyway", ctrl.OldValue) Then
-
'If it has changed from its originalvalue highligth it
-
ctrl.BorderColor = vbRed
-
ctrl.BorderWidth = 3
-
End If
-
Else
-
'False means return to normal view
-
ctrl.BorderColor = 0
-
ctrl.BorderWidth = 1
-
End If
-
-
End If
-
Next
-
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.
when u call highlightchanges in before update what do yu pass as argument,...boolean true?
i passed boolean true as argument and the highlight was not done
but the code gets executed where
# ctrl.BorderColor = vbRed
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?
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.
Im guessing you have border style set as transparent then :)
can u provide code for concatenating the changed values in string
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. - Public Function fncChanges(myForm As Form) As String
-
Dim ctrl As Control
-
Dim strChanges As String
-
Dim intChanges As Integer
-
Dim intI As Integer
-
-
For Each ctrl In myForm.Controls
-
If Not myForm.Dirty Then
-
strChanges = "No changes Made"
-
fncChanges = strChanges
-
Exit Function
-
End If
-
-
'accombobox
-
If ctrl.ControlType = acComboBox Then
-
'Is it bound?
-
If (ctrl.ControlSource & "") <> "" Then
-
'Yes it is
-
-
'Has anything changed?
-
If (ctrl.OldValue & "") <> (ctrl.Value & "") Then
-
'Does it have more then 1 column?
-
If ctrl.ColumnCount = 1 Then
-
'It only has 1, probably a simple combobox
-
strChanges = strChanges & "Field [" & ctrl.ControlSource & "] has changed from {" & ctrl.OldValue & "} to {" & ctrl.Value & "}" & vbNewLine
-
intChanges = intChanges + 1
-
Else
-
'It has more then 1
-
-
'Are column widths specified?
-
If (ctrl.ColumnWidths & "") <> "" Then
-
'They are, retrieve first
-
-
For intI = 0 To InStr(1, ctrl.ColumnWidths, ";")
-
If Split(ctrl.ColumnWidths, ";")(intI) <> 0 Then
-
strChanges = strChanges & "Field [" & ctrl.ControlSource & "] has changed to {" & ctrl.Column(intI) & "}" & vbNewLine 'Note the ctrl.oldvalue wont do much good on a combobox
-
Exit For
-
End If
-
Next
-
-
-
Else
-
'Haven't figured out have ot handle this case.
-
strChanges = strChanges & "Bad case handle on Field [" & ctrl.ControlSource & "]" & vbNewLine
-
intChanges = intChanges + 1
-
End If
-
-
-
End If
-
End If
-
-
-
End If
-
End If
-
Next
-
fncChanges = strChanges
-
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)
thanks for the code smiley one ..
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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 =...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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: 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,...
| |