copy from table to form

DeanRowe

Registered User.
Local time
Today, 23:14
Joined
Jan 26, 2007
Messages
142
Hi,
I have a table [Table A] - it contains two fields:
[Date ID] & [Date]

To enter the details into this table we use a [Date] form.

There is only ever one record, because when a user writes a date into the [Date] Form it overwrites the old date that was in [Table A].

I want to be able to copy the date from [Table A] into a field on another form, without having the need to keep the [Date] Form open in the background and do a copy command - any recommendations on how to do this?

I know it sounds silly but we need to manually write a date every day because we get paid 3 working days later, and because of weekends and bank holidays it has to be done like this.

Thank you for your time.

Dean
 
on your "other" form's On Open event (or button click):

Me.DateField = DLookup("Date", "tblDate")
 
Hi Wazz,

Thank you for responding. Rather stupidly I've named all my fields and tables "Paid in Date" - so the following code is a little confusing - here's what I entered:

"Private Sub Command234_Click()
Me.[Paid_In_Date] = DLookup("Paid in Date", "Paid in Date")
End Sub"

However the following error comes up:

"Runtime error "3075":
In operator without () in query expression "Paid in Date"."

Any ideas what this is? I've tried putting each field and table in [brackets] instead of "speech marks" but no luck.

Thank you for your help Wazz, its greatly appreciated.

"
 
Dean,

Me.[Paid_In_Date] = DLookup("[Paid in Date]", "Paid in Date")

Wayne
 
Beautiful, thank you Wazz for your help. I setup a command button using that code and it works perfectly....

One last question if I may? Do you know how I can use that code as part of a Macro?
I already have a button that runs a macro on the form, so I was hoping to add that code to the macro so i don't have to have two seperate buttons on the form.

I tried the code using the "RunCode" option but can't get it to work, even when I take away the "Me." part.

Any ideas? If not, I just wanted to say thank you for getting me this far, it's a great help and is appreciated hugely.

Dean
 
Dean,

Upon further review ...

Me.[Paid_In_Date] = DLookup("[Paid in Date]", "[Paid in Date]")

Darned spaces,
Wayne
 
Sorry WayneRyan, it was your code I used before my last post and it worked fine, so thank you - any idea on the Macro problem?
Cheers again
 
try SetValue. item is your field, expression is the code above. (haven't used macros for a bit).
 

Users who are viewing this thread

Back
Top Bottom