Currently I have code that does 3 things.
- It links an image to a clickable word using an Iframe
- It has the ability to add comments
- It displays the comments.
What I am trying to do if it's possible is to have the comments that are displayed tied to the image being displayed. Then when anyone submits a comment it is added to the specific list of the comments tied to the image. Is this possible?
In simpler terms is there a way to link an access table with one specific entry in another table.
Here is what I have so far.
<cfquery datasource="AccessTest" name="qTest">
SELECT Account, Image
FROM ElectricList
</cfquery>
<cfquery datasource="AccessTest" name="qTest2">
SELECT Account, Image
FROM GasList
</cfquery>
<cfquery datasource="AccessTest" name="qTest3">
SELECT Accounts, Remarks, Users
FROM Comments
</cfquery>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Demo</title>
</head>
<body>
<h3>Demo</h3>
<iframe name="viewframe" style="display:block;height:Float;width:965px;float:left">
</iframe>
<cflayout name="myAccordionLayout" type="accordion" width="600px">
<cflayoutarea title="Electric Accounts" align="left">
<cfoutput query="qTest">
<tr>
<td>
<a href=#qTest.Image#" target="viewframe">#qTest.Account#</a>
</td>
</tr>
</cfoutput>
</cflayoutarea>
<cflayoutarea title="Gas Accounts">
<cfoutput query="qTest2">
<tr>
<td>
<a href=#qTest2.Image#" target="viewframe">#qTest2.Account#</a>
</td>
</tr>
</cfoutput>
</cflayoutarea>
</cflayout>
<table width="600" border="1" cellspacing="0">
<cfoutput query="qTest3">
<tr>
<td>
#qTest3.Accounts#
#qTest3.Remarks#
#qTest3.Users#
</td>
</tr>
</cfoutput>
<cfform name="insertComments" id="insertComments">
<fieldset>
<p>
<label for="Accounts">Accounts</label>
<br/>
<cfinput type="text" name="Accounts" message="Please enter a Comment Title." validateat="onSubmit" required="yes" id="Accounts" size="60">
</p>
<p>
<label for="Remarks">Remarks<br/></label>
<cftextarea name="Remarks" cols="55" rows="4" label="Tour Description" required="yes" validateat="OnSubmit" message="Please enter your comment here" enabled="no">
</cftextarea>
</p>
<p>
<label for="Users">Submitters Name</label>
<br/>
<cfinput type="text" name="Users" message="Please enter your name here." validateat="onSubmit" required="yes" id="Name" size="10" maxlength="60">
</p>
<p>
<cfinput type="submit" name="insertComments" value="Insert Comments" id="submit">
</p>
</fieldset>
</cfform>
<cfif IsDefined("form.InsertComments")>
<cfquery datasource="AccessTest">
INSERT INTO Comments (Accounts, Remarks, Users)
VALUES ('#form.Accounts#','#form.Remarks#','#form.Users#')
</cfquery>
</cfif>
</body>
</html>
Yes, assuming your current table has images in it along with an ImageID key, you would create a second table for comments linking to Foreign key imageID from your images table in the relationships. Then you create a sub-form in your main form to display/edit the comments.
That way each comment is linked to only one image, but each image can have multiple comments.
EDIT: Follow this guide for creating a sub-form.
http://www.techonthenet.com/access/subforms/link.php