Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run query from macro to populate a form field 1

Status
Not open for further replies.

lkuch

Programmer
May 8, 2002
5
US
I have a query I created to convert a date field to 4-digit julian date.
Code use:
SELECT Transactions.TransactionDate, Format(Format([TransactionDate],"y"),"3000") AS Julian
FROM Transactions;
My query shows two columns - TransactionDate and julian.
The macro runs good manually but I want to have the query run in the background and not open up as datasheet, and have the outputed julian number populate another text field in my form. How can I do this?

Problem, when I select the record source in the text field I want populated, all I can select from is the fields from my form's record source(which is my Transactions table)and when I use the expression builder to select my query instead and open the form, my text field shows...#Name? What am I doing wrong?.

Regards!
 
Set the ControlSource of that field to -
=Format(Format([TransactionDate],"y"),"3000")
 
If you want the control to be a bound control to a table so that the Julian value is saved then you must make the assignment of the value in the OnCurrent Event Procedure and the AfterUpdate of the control TransactionDate:

Me.JulianValue = Format(Format([TransactionDate],"y"),"3000")

Now you can make the control Bound to your table/query field.


Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Thank You, Bob!
Your expertise got me out of a jam.
Thanks again!

Lou Kuchenbrod
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top