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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Constant field.

Status
Not open for further replies.

JohnStep

Programmer
Apr 19, 2000
190
US
&nbsp;&nbsp;How can I make one field constant from the first entry in a database? For example I have a field Date. I want all the records to mimic the date entered on the first record 1. The date should remain constant for all the&nbsp;&nbsp;records.<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Any help would be appreciated,<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;John Stephens
 
<br>How about ...<br><br>.. creating a table with one field intended to hold one record. The date record is added to this 'datetable' if it doesn't exist, otherwise it doesn't get added; as in code below;<br><br>&quot;SELECT count(*) as TableOfInterestCount from TableOfInterest&quot;.<br>&nbsp;<br>&nbsp;If TableOfInterestCount = 0 them<br>&nbsp;&nbsp;&quot;SELECT Count(*) as Count from datetable&quot;.<br>&nbsp;&nbsp;&nbsp;If Count = 0 them<br>&nbsp;&nbsp;&nbsp;&quot;INSERT INTO datetable (theDate) VALUES (#&quot; & now() &&quot;#)&quot;<br>&nbsp;&nbsp;&nbsp;else <br>&nbsp;&nbsp;&nbsp;&nbsp;' Cant happen ! <br>&nbsp;&nbsp;&nbsp;end If<br>&nbsp;else <br>&nbsp;&nbsp;&nbsp;&nbsp;'some code to disarm, but not delete, the query that&nbsp;&nbsp;&nbsp;updates the datetable... <br>&nbsp;end If<br><br>Since this is the only code that writes to the table and it gets called when records are saved in the table(s) in question, we are assuerd to always have the first date as the only date that will ever be used, as in;<br><br>A select query to 'attach' that date to each record that requires it.<br><br>&quot;SELECT * FROM datetable, table1&quot;, or<br>&quot;SELECT * FROM datetable, table1 where subject = 'paperclip'&quot;<br><br>The date from the datetable will appear in every record returned.<br> <p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top