initial values of FP form fields

  • Thread starter Thread starter TB
  • Start date Start date
T

TB

I am trying to make a form whereby I can change the values of certain fields
in a database (MDB) of my site.

Whereas I can populate the normal FP text fields with the current values of
the selected register by setting "initial value to something like
"<%=FP_FieldHTML(fp_rs,"NAME")%>" (is there another to do that?), I do know
how to do that with an FP drop-down box (where the of course the
corresponding value of the selected register must coincide with one of the
choices available in that drop-down box.)

Any advice will appreciated. Thanks

Trym
 
If the drop-down list is hard-coded, switch to Code view
and modify each <option> tag so it looks like this:

<option value="smith"<%
if FP_FieldHTML(fp_rs,"NAME") = "smith"
response.write " selected"
end if
%>>Smith</option>

If you're using a second DRW to generate the drop-down
list from the database, refer to the article at:

Persisting the Selection in a Drop-Down Box
http://www.interlacken.com/winnt/tips/tipshow.aspx?tip=49

but on line 3 of the sample code, replace
request("myfield")
with
FP_FieldHTML(fp_rs,"myfield")

BTW, you are perilously close to the point where coding
this from scratch in ASP or ASP.NET would be easier than
poking and patching around the "helpful" FrontPage
components.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
Thanks for your advice. I will test it and get back to you.

As for your final comment. You are perfectly right, but my problem is my
love-hate relationship with DRW, the reason being my virtually non-existing
knowledge of programming. I like the point-and-click ease of DRW, but hate
the restrictions that it imposes on the final result which never suits my
needs. Therefore I usually run the DRW and the go through (for me) the risky
process of modifying the code through trial-and-error.

Now, I would love to be able to write all the stuff myself, but the amount
of code that FP generates inside the multitude of pages that constitute the
DRW end-result somehow hold me back from making a effort to learn
programming.

Now if you tell me that 90% the code / pages that the DRW creates is
superfluous fat and that it is really easy to write your own data access
pages, then I would definitely make an effort to learn how to do it.
However, if there exists a point-and-click alternative to the DRW (like an
add-in) which permits more flexibility and allows editing pages already
made, then that would be even better.

Trym
 
Well, here's a complete ASP page that queries and displays four fields
from the ubiquitous Northwind database:

<html>
<head>
<title>Display Employees</title>
</head>
<body>
<%
Dim cnMyDb
Dim rsEmpl
Dim sql

' Open Database Connection
Set cnMyDb = Server.CreateObject("ADODB.Connection")
cnMyDb.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & _
Server.MapPath("fpdb/fpnwind.mdb") & ";"

' Open Recordset
sql = "SELECT * FROM employees ORDER BY LastName "
Set rsEmpl = Server.CreateObject("ADODB.Recordset")
rsEmpl.Open sql, cnMyDb

' Display titles
%><table>
<tr>
<th>Employee ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Hire Date</th>
</tr><%

' Loop through all records
do until rsEmpl.Eof
%>
<tr>
<td><%=rsEmpl("EmployeeID")%></td>
<td><%=rsEmpl("FirstName")%></td>
<td><%=rsEmpl("LastName")%></td>
<td align="right"><%=FormatDateTime(rsEmpl("HireDate"),vbShortDate)%></td>
</tr>
<%
rsEmpl.MoveNext
loop

' Cleanup
rsEmpl.close
cnMyDb.close
set rsEmpl = Nothing
set cnMtDb = Nothing
%>
</table>
</body>
</html>

Does that look so tough?

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
You are right. It doesn't look that complicated. I have tested it with my
MDB and it worked. Is a page that edits existing records just as simple? And
a page to add new records? (thereby substituting totally DRW).

Or am I asking for too much?

Trym
 
For help in writing an ASP page that adds records, refer to:

Saving Form Data in a Database
http://www.interlacken.com/winnt/tips/tipshow.aspx?tip=44

Updating theoretically isn't any more difficult than inserting;
you just use an UPDATE command rather than an INSERT command.
However, there tends to be a lot more logic involved in retrieving
the initial field values, running syntax checks, and recycling
the page until all teh field values are OK and the update works.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
Thanks again for your advice. I am more or less ready to dive in and make an
effort to learn ASP coding from scratch. However, for this to have any
practical result I suppose the correct thing would be first to get
profecient in HTML programming. Searching on the internet, I have found a
book called: "Sams Teach Yourself HTML and XHTML in 24 Hours" (see:
http://www.amazon.co.uk/exec/obidos...773/ref=sr_8_xs_ap_i1_xgl/026-1653079-2070861),
which seems to have received good reviews as a tool for learning HTML from
scratch. Any opinions on that book (apart from the title, which is not so
appealing)?

Trym
 
Sorry, the last time I bought an HTML book was probably 1995 or so.
The book you mention might be wonderful or terrible and I absolutely
wouldn't know.

For the most part, I'd recommend looking for a short, simple book that
gives you the mindset of HTML and CSS. After that, you can easily
understand the reference material at www.w3c.org or
msdn.microsoft.com.

One nice thing about going to a bookstore is that you can try looking
up a couple of current questions in the index or the table of
contents, and see how much you like the answers (if any).

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
OK. Thanks for your time anyway. Once I become sufficiently "advanced", I
will have a look at your books as well.

I love going to bookstores, but my problem is that I live in a tiny village
in mountainous area of Spain, where - as you can imagine - there is far
between English-language book stores.

Trym
 

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

Back
Top