Insert record, increment a number by 1

A

Allan

have a table called ContainerStops. One field in the table called StopNum
needs to be entered by addding a '-1', ,'-2', '-3', etc to the data contained
in the Field IDContainer. For example:

IDCONTAINER STOPNUM
GVN2345 GVN2345-1
GVN2345 GVN2345-2
GVN2345 GVN2345-3
GVN2345 GVN2345-4

The first two records for each Container I insert at one time using the
following code below.

Now what I nede to be able to do is insert the next record, in this case
GVN2345-3 by having the code look at the table field STOPNUM and see what
number should come next based on the IDCONTAINER data and the next number to
be incremented.

I hope this make sense. Any help much appreciated.




<!--#include file="../_fpclassx/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database
Results component on this page is unable to display database content. The
page must have a filename ending in '.asp', and the web must be hosted on a
server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
If IsDate(Request.Form("LastFreeDay")) Then
LastFreeDay="#"&Request.Form("LastFreeDay")&"#"
Else LastFreeDay="Null"
End If
If IsDate(Request.Form("LastReceivableDate")) Then
LastReceivableDate="#"&Request.Form("LastReceivableDate")&"#"
Else LastReceivableDate="Null"
End If
%>
<%
fp_sQry="INSERT INTO ContainerStops (IDContainer, StopNum, ContainerState,
LastFreeDay, LastReceivableDate, AppointmentTime, SealNum, UnloadTime,
DriverWait, Driver, ForkliftCharges, Charges, InLine, InGate, Exit,
PUIDProfileStop, PUCompany, PUFirstName, PULastName, PUPhone,
PUStreetAddress, PUCity, PUState, PUZip, DelIDProfileStop, DelCompany,
DelFirstName, DelLastName, DelPhone, DelStreetAddress, DelCity, DelState,
DelZip, ContainerStopNotes, AccountCode) VALUES :):IDContainer::,
'::IDContainer::-1', '::ContainerState::', "&LastFreeDay&",
"&LastReceivableDate&", '::AppointmentTime::', '::SealNum::',
'::UnloadTime::', '::DriverWait::', '::Driver::', ::ForkliftCharges::,
::Charges::, '::InLine::', '::InGate::', '::Exit::', '::pUIDProfileStop::',
'::pUCompany::', '::pUFirstName::', '::pULastName::', '::pUPhone::',
'::pUStreetAddress::', '::pUCity::', '::pUState::', '::pUZip::',
'::DelIDProfileStop::', '::DelCompany::', '::DelFirstName::',
'::DelLastName::', '::DelPhone::', '::DelStreetAddress::', '::DelCity::',
'::DelState::', '::DelZip::', '::ContainerStopNotes::', '::AccountCode::')"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=16 align=""LEFT"" width=""100%""></td></tr>"
fp_sDataConn="sms"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&"
fp_iDisplayCols=16
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../_fpclassx/fpdbrgn1.inc"-->
<!--#include file="../_fpclassx/fpdbrgn2.inc"-->
</tbody>
</table>

<p> </p>

<table width="100%" border="0" id="table58" height="20" cellspacing="0"
cellpadding="0">
<thead>
</thead>
<tbody>
<!--#include file="../_fpclassx/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database
Results component on this page is unable to display database content. The
page must have a filename ending in '.asp', and the web must be hosted on a
server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
If IsDate(Request.Form("LastFreeDay")) Then
LastFreeDay="#"&Request.Form("LastFreeDay")&"#"
Else LastFreeDay="Null"
End If
If IsDate(Request.Form("LastReceivableDate")) Then
LastReceivableDate="#"&Request.Form("LastReceivableDate")&"#"
Else LastReceivableDate="Null"
End If
%>
<%
fp_sQry="INSERT INTO ContainerStops (IDContainer, StopNum, ContainerState,
LastFreeDay, LastReceivableDate, AppointmentTime, SealNum, UnloadTime,
DriverWait, Driver, ForkliftCharges, Charges, InLine, InGate, Exit,
PUIDProfileStop, PUCompany, PUFirstName, PULastName, PUPhone,
PUStreetAddress, PUCity, PUState, PUZip, DelIDProfileStop, DelCompany,
DelFirstName, DelLastName, DelPhone, DelStreetAddress, DelCity, DelState,
DelZip, ContainerStopNotes, AccountCode) VALUES :):IDContainer::,
'::IDContainer::-2', 'Empty', "&LastFreeDay&", "&LastReceivableDate&",
'::AppointmentTime::', '::SealNum::', '::UnloadTime::', '::DriverWait::',
'::Driver::', ::ForkliftCharges::, ::Charges::, '::InLine::', '::InGate::',
'::Exit::', '::DelIDProfileStop::', '::DelCompany::', '::DelFirstName::',
'::DelLastName::', '::DelPhone::', '::DelStreetAddress::', '::DelCity::',
'::DelState::', '::DelZip::', '::pUIDProfileStop::', '::pUCompany::',
'::pUFirstName::', '::pULastName::', '::pUPhone::', '::pUStreetAddress::',
'::pUCity::', '::pUState::', '::pUZip::', '::ContainerStopNotes::',
'::AccountCode::')"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=16 align=""LEFT"" width=""100%""></td></tr>"
fp_sDataConn="sms"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&"
fp_iDisplayCols=16
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../_fpclassx/fpdbrgn1.inc"-->
<!--#include file="../_fpclassx/fpdbrgn2.inc"-->
 

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

Top