Set data from va to a form field

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
 
J

John Hawker

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

JH
 
L

Linq Adams via AccessMonster.com

How/where are you retrieving the value for maradte, and how/where are you
assigning the DefaultValue? A DefaultValue is assigned to the record the
instant a new record is dirtied. I suspect that your code is retrieving its
value after this point in time.
 
I

IKMD66

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
 
D

Dirk Goldgar

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 & "#"
 
I

IKMD66

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top