dgi001
asked on
Creating a History Field in Microsoft Access 2007
Hi
I am trying to create a history field to record all actions typed in the notes field of my form.
When you type any data in the notes field and click the save button, the data in the notes section is copied to history field, and any data in the notes field is removed. To do this i am using the following code:
-------------------------- --------
To update the History field with the data from the Notes field.
Private Sub txtSatNavNotes_AfterUpdate ()
If Me.txtSatNavHistory = "" Then
Me.txtSatNavHistory = Me.txtSatNavHistory & Me.txtSatNavNotes
Else
Me.txtSatNavHistory = Me.txtSatNavHistory & vbNewLine & Me.txtSatNavNotes
End If
End Sub
When i click my Save button, it clears the Notes field:
Me.txtSatNavNotes = ""
-------------------------- ---------- ---
The issue i have is that the history field in the underlying table is not being populated with the data that is being copied to the history field that is on the form, even though it is showing when you load the form.
What am i doing wrong?
I hope this makes sense.
kind regards
DGI
I am trying to create a history field to record all actions typed in the notes field of my form.
When you type any data in the notes field and click the save button, the data in the notes section is copied to history field, and any data in the notes field is removed. To do this i am using the following code:
--------------------------
To update the History field with the data from the Notes field.
Private Sub txtSatNavNotes_AfterUpdate
If Me.txtSatNavHistory = "" Then
Me.txtSatNavHistory = Me.txtSatNavHistory & Me.txtSatNavNotes
Else
Me.txtSatNavHistory = Me.txtSatNavHistory & vbNewLine & Me.txtSatNavNotes
End If
End Sub
When i click my Save button, it clears the Notes field:
Me.txtSatNavNotes = ""
--------------------------
The issue i have is that the history field in the underlying table is not being populated with the data that is being copied to the history field that is on the form, even though it is showing when you load the form.
What am i doing wrong?
I hope this makes sense.
kind regards
DGI
What does the Save button do? There might be a timing issue here. Make sure you don't clear the Notes textbox before saving. Save first.
Also, use Nz() to check for nulls. "" is not the same as a Null field:
If Nz(Me![txtSatZNavHistory]. Value) <> "" Then
This will cover both Nulls and empty strings in the field.
If Nz(Me![txtSatZNavHistory].
This will cover both Nulls and empty strings in the field.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
My try this:
I have fioudn inthe 15+ years working with Acess that your method can lead to dfata loss.
I find it much better to save each new notes as a separate record. This has many advantages. For example I use a separate date/time field. This allows the notes to be sorted and filtered.
Private Sub txtSatNavNotes_AfterUpdate()
If Me.txtSatNavHistory = "" Then
Me.txtSatNavHistory = Me.txtSatNavNotes
Else
Me.txtSatNavHistory = Me.txtSatNavHistory & vbNewLine & Me.txtSatNavNotes
End If
End Sub
I have fioudn inthe 15+ years working with Acess that your method can lead to dfata loss.
I find it much better to save each new notes as a separate record. This has many advantages. For example I use a separate date/time field. This allows the notes to be sorted and filtered.
A question, is "Me.txtSatNavHistory" a textbox?...
you should use "Me.txtSatNavHistory.TEXT" instead
of "Me.txtSatNavHistory"
you should use "Me.txtSatNavHistory.TEXT"
of "Me.txtSatNavHistory"
ASKER
Hi Capricorn
I have looked at the Column History but i cant get it to work.
My table tblSimDetails has a column called SIMNotes, memo data type and append only set to yes.
I have a form called frmSimDetails where i am trying to copy the data from the txtSimNotes field to the txtSIMHistory field by making the txtSIMHistory control source set to:
=ColumnHistory([RecordSour ce],"txtSI MNotes","[ txtSIMNoID ]=" & Nz([txtSIMNoID],0)).
When i load the form, the txtSIMHistory reads #error.
Am i being stupid in that the [RecordSource] shoudl be the name of the table or form? I did but those details in but that didnt work either.
What am i doing wrong?
Kind regards
DGI
I have looked at the Column History but i cant get it to work.
My table tblSimDetails has a column called SIMNotes, memo data type and append only set to yes.
I have a form called frmSimDetails where i am trying to copy the data from the txtSimNotes field to the txtSIMHistory field by making the txtSIMHistory control source set to:
=ColumnHistory([RecordSour
When i load the form, the txtSIMHistory reads #error.
Am i being stupid in that the [RecordSource] shoudl be the name of the table or form? I did but those details in but that didnt work either.
What am i doing wrong?
Kind regards
DGI
what is the Record Source of the form?
ASKER
tblSimDetails
tblSimDetails
fields
SIMNoID > is this Number Data Type or Text?
SIMNotes > Memo
try this
=ColumnHistory([RecordSour ce],"SIMNo tes","[SIM NoID]=" & Nz([txtSIMNoID],0))
fields
SIMNoID > is this Number Data Type or Text?
SIMNotes > Memo
try this
=ColumnHistory([RecordSour
ASKER
SimNoID is an autoNumber data type
I tried what you suggested and still comes up with #error.
I tried what you suggested and still comes up with #error.
how about this
=ColumnHistory("tblSimDeta ils","SIMN otes","[SI MNoID]=" & Nz([txtSIMNoID],0))
=ColumnHistory("tblSimDeta
ASKER
Hi
I dont know what is stopping this from working on all my forms as i have created a test database from scratch and it works using =ColumnHistory([RecordSour ce],"SIMNo tes","[SIM NoID]=" & Nz([txtSIMNoID],0)).
I wonder if some code or other settning is preventing this from working? i am not quite sure what to do next, except rebuild my forms?
regards
DGI
I dont know what is stopping this from working on all my forms as i have created a test database from scratch and it works using =ColumnHistory([RecordSour
I wonder if some code or other settning is preventing this from working? i am not quite sure what to do next, except rebuild my forms?
regards
DGI
ASKER
I have imported all my tables, forms and modules into a new database and this now works?????
Does this mean that my database is corrupt or because its Micrsoft?
kind regards
DGI
Does this mean that my database is corrupt or because its Micrsoft?
kind regards
DGI
your form could be corrupted :-(
try this,
delete the =ColumnHistory([RecordSour ce],"SIMNo tes","[SIM NoID]=" & Nz([txtSIMNoID],0))
from the Control Source of the textbox
save the form
do this
Tools >Database utilities > compact and repair database
* do a decompile
see this link
http://www.granite.ab.ca/access/decompile.htm
* after that,
* open the VBA window and do
Debug > Compile
correct any errors raised
* do a compact and repair
Now go back to the form and add to the Control Source of the textbox
=ColumnHistory([RecordSour ce],"SIMNo tes","[SIM NoID]=" & Nz([txtSIMNoID],0))
try this,
delete the =ColumnHistory([RecordSour
from the Control Source of the textbox
save the form
do this
Tools >Database utilities > compact and repair database
* do a decompile
see this link
http://www.granite.ab.ca/access/decompile.htm
* after that,
* open the VBA window and do
Debug > Compile
correct any errors raised
* do a compact and repair
Now go back to the form and add to the Control Source of the textbox
=ColumnHistory([RecordSour
oops, cross posting... :-)
ASKER
I will do this over the weekend and get back to you.
ASKER
If i ignore the fact that my database was corrupt, and i have now resolved this, this suggestion resolved the my request.
Thanks to all who replied.
Thanks to all who replied.