I look at a lot of files to see when they were last updated.
I wanted to write a generic procedure to manage that so …..
What I hoped Me.vField would do is update the date field [txt_gts_data] on my form with the date the file was last saved.
i.e. me. txt_gts_data = fDate
What actually happens is the variable vfield gets updated from “txt_gts_data” to 19/08/2014 then later code falls over because the fieldname is lost :-(.
Me.[vField] corrects itself to me.vField (and does not work)
Me!vfield falls over (cannot find the field vField, not surprising J)
How do I say update the contents of the variable, not the variable itself?
I wanted to write a generic procedure to manage that so …..
Code:
[FONT=Arial][COLOR=blue][COLOR=blue][FONT=Arial]Public fDate As Variant[/FONT][/COLOR]
[COLOR=blue][FONT=Arial]Public vField As String[/FONT][/COLOR]
[COLOR=blue][FONT=Arial]Public vFile As String[/FONT][/COLOR]
[COLOR=blue][FONT=Arial]'GTSdata [/FONT][/COLOR]
[COLOR=blue][FONT=Arial]vField = "txt_gts_data"[/FONT][/COLOR]
[COLOR=blue][FONT=Arial]vFile = "c:\gtsdata\gts_data.txt" [/FONT][/COLOR]
[COLOR=blue][FONT=Arial]Call form_open_data(vField, vFile)[/FONT][/COLOR]
[COLOR=blue][FONT=Arial]------------------------------------------------------ [/FONT][/COLOR]
[COLOR=blue][FONT=Arial]Private Sub form_open_data(vField, vFile)[/FONT][/COLOR]
[COLOR=blue][FONT=Arial]fDate = Format(FileDateTime(vFile), "dd/mm/yyyy")[/FONT][/COLOR]
[COLOR=blue][FONT=Arial]Me.vField = fDate '<<<<<<<<<<<<<<WRONG !!!!![/FONT][/COLOR]
[COLOR=blue][FONT=Arial]If DateValue(txt_DateToday) - DateValue(vField) < 5 Then[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] vField.BackColor = "64636" 'Green[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] etc. etc.[/FONT][/COLOR]
[/COLOR][/FONT]
What I hoped Me.vField would do is update the date field [txt_gts_data] on my form with the date the file was last saved.
i.e. me. txt_gts_data = fDate
What actually happens is the variable vfield gets updated from “txt_gts_data” to 19/08/2014 then later code falls over because the fieldname is lost :-(.
Me.[vField] corrects itself to me.vField (and does not work)
Me!vfield falls over (cannot find the field vField, not surprising J)
How do I say update the contents of the variable, not the variable itself?