Re: initial values of FP form fields

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Jim Buyens (news_at_interlacken.com)
Date: 08/11/04


Date: 10 Aug 2004 22:49:08 -0700

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)
|/---------------------------------------------------
*----------------------------------------------------

"TB" <tbpostbox-googlegroups@yahoo.com> wrote in message news:<#znCX#xfEHA.3544@TK2MSFTNGP10.phx.gbl>...
> 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
>
>
> "Jim Buyens" <news@interlacken.com> wrote in message
> news:36a7e008.0408071617.42bb0c32@posting.google.com...
> > 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)
> > |/---------------------------------------------------
> > *----------------------------------------------------
> >
> >
> > "TB" <tbpostbox-googlegroups@yahoo.com> wrote in message
> news:<OQqqzeJfEHA.396@TK2MSFTNGP12.phx.gbl>...
> > > 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
> > >
> > > "Jim Buyens" <news@interlacken.com> wrote in message
> > > news:0cc001c47b0e$6880b300$a401280a@phx.gbl...
> > > > 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)
> > > > |/---------------------------------------------------
> > > > *----------------------------------------------------
> > > >
> > > >
> > > > >-----Original Message-----
> > > > >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
> > > > >
> > > > >
> > > > >
> > > > >.
> > > > >



Relevant Pages

  • Re: initial values of FP form fields
    ... Dim cnMyDb ... ' Open Database Connection ... Set cnMyDb = Server.CreateObject ... Microsoft FrontPage MVP ...
    (microsoft.public.frontpage.client)
  • Re: export data from asp to .mdb?
    ... I am currently trying to get a simple data submission asp form to export ... dim Name ... Database was successfully updated. ... Dim sMSG ...
    (microsoft.public.inetserver.asp.db)
  • re: Updating table from a session variable.
    ... >I think you've outgrown the database results wizard. ... >probably need to code this in ASP. ... >(albeit using an INSERTY statement, ... >Microsoft FrontPage MVP ...
    (microsoft.public.frontpage.programming)
  • re: Deleting Records from Access...using FP2003
    ... the ASP DRW doesn't deal well with queries ... Dim cnMyDb ... Saving Form Data in a Database ... Microsoft FrontPage MVP ...
    (microsoft.public.frontpage.programming)
  • RE: Questions about asp 3.0 and aspnets differences
    ... mostly regarding the use of forms and database use. ... I have some pages on asp 3.0 that are like this: ... Dim dbconn = New ... i have used the new controls that you just drag and drop ...
    (microsoft.public.dotnet.framework.aspnet)