Set data from va to a form field

  • Thread starter Thread starter IKMD66
  • Start date Start date
I

IKMD66

Hi,

Appreciate all the help I get here.

I cannot figure out how to do this hence the post.

I retrieve a file date and time from a filein C:\Temp using the code below:

If Dir("C:\Temp\MARA_ZVRP.xls") <> "" Then
maradte = FileDateTime("C:\Temp\MARA_ZVRP.xls")

I then want to set a form field with the value retrieved If I use

Forms![Initialised Form]!MARA_File.DefaultValue = maradte

it doesn't work, however if i use

Forms![Initialised Form]!MARA_File.DefaultValue = """TEST"""

I get "TEST" returned to the form field.

the value for maradte (if debugged) is 23/09/2008 09:19:32

Can anyone point me in the right direction?

Thanks in advance.

Regards,
Kirk
 
Do you get a #13 Data type mismatch error? If so, it may be because
..DefaultValue is a String value. Try ... = CStr(maradte)

JH
 
John,

I tried what you suggested and now get the form field populated with "#Name?"

As stated before if I use """TEST""" the form fieild is set to TEST.

Perhaps I am missing something related to formatting or perhaps DefaultValue
is not the correct option to use?

Any further pointers would be appreciated.

Note the code is set to run On Load.

Cheers,
Kirk

John Hawker said:
Do you get a #13 Data type mismatch error? If so, it may be because
.DefaultValue is a String value. Try ... = CStr(maradte)

JH

IKMD66 said:
Hi,

Appreciate all the help I get here.

I cannot figure out how to do this hence the post.

I retrieve a file date and time from a filein C:\Temp using the code below:

If Dir("C:\Temp\MARA_ZVRP.xls") <> "" Then
maradte = FileDateTime("C:\Temp\MARA_ZVRP.xls")

I then want to set a form field with the value retrieved If I use

Forms![Initialised Form]!MARA_File.DefaultValue = maradte

it doesn't work, however if i use

Forms![Initialised Form]!MARA_File.DefaultValue = """TEST"""

I get "TEST" returned to the form field.

the value for maradte (if debugged) is 23/09/2008 09:19:32

Can anyone point me in the right direction?

Thanks in advance.

Regards,
Kirk
 
IKMD66 said:
Hi,

Appreciate all the help I get here.

I cannot figure out how to do this hence the post.

I retrieve a file date and time from a filein C:\Temp using the code
below:

If Dir("C:\Temp\MARA_ZVRP.xls") <> "" Then
maradte = FileDateTime("C:\Temp\MARA_ZVRP.xls")

I then want to set a form field with the value retrieved If I use

Forms![Initialised Form]!MARA_File.DefaultValue = maradte

it doesn't work, however if i use

Forms![Initialised Form]!MARA_File.DefaultValue = """TEST"""

I get "TEST" returned to the form field.

the value for maradte (if debugged) is 23/09/2008 09:19:32

Can anyone point me in the right direction?

Thanks in advance.


Try this:

Forms![Initialised Form]!MARA_File.DefaultValue = "#" & maradte & "#"
 
Dirk,

Excellent - this worked as specified.

Greatly appreciated - I spent a few hours playing around with this and
couldn't get the syntax correct.

Thanks again (to the others too) for your assistance.

Regards,
Kirk

Dirk Goldgar said:
IKMD66 said:
Hi,

Appreciate all the help I get here.

I cannot figure out how to do this hence the post.

I retrieve a file date and time from a filein C:\Temp using the code
below:

If Dir("C:\Temp\MARA_ZVRP.xls") <> "" Then
maradte = FileDateTime("C:\Temp\MARA_ZVRP.xls")

I then want to set a form field with the value retrieved If I use

Forms![Initialised Form]!MARA_File.DefaultValue = maradte

it doesn't work, however if i use

Forms![Initialised Form]!MARA_File.DefaultValue = """TEST"""

I get "TEST" returned to the form field.

the value for maradte (if debugged) is 23/09/2008 09:19:32

Can anyone point me in the right direction?

Thanks in advance.


Try this:

Forms![Initialised Form]!MARA_File.DefaultValue = "#" & maradte & "#"

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top