Article ID: 166911
Article Last Modified on 1/19/2007
If cstr(Request.QueryString("Country")) <> "" Then
rs.Fields("Country").Value = Request.QueryString("Country")
End If
If cstr(Request.QueryString("Fax")) <> "" Then
rs.Fields("Fax").Value = Request.QueryString("Fax")
End If
If cstr(Request.QueryString("Phone")) <> "" Then
rs.Fields("Phone").Value = Request.QueryString("Phone")
End If
If cstr(Request.QueryString("PostalCode")) <> "" Then
rs.Fields("PostalCode").Value = Request.QueryString("PostalCode")
End If
If cstr(Request.QueryString("Region")) <> "" Then
rs.Fields("Region").Value = Request.QueryString("Region")
End If
If cstr(Request.QueryString("City")) <> "" Then
rs.Fields("City").Value = Request.QueryString("City")
End If
If cstr(Request.QueryString("Address")) <> "" Then
rs.Fields("Address").Value = Request.QueryString("Address")
End If
If cstr(Request.QueryString("ContactTitle")) <> "" Then
rs.Fields("ContactTitle").Value = _
Request.QueryString("ContactTitle")
End If
If cstr(Request.QueryString("ContactName")) <> "" Then
rs.Fields("ContactName").Value = _
Request.QueryString("ContactName")
End If
If cstr(Request.QueryString("CompanyName")) <> "" Then
rs.Fields("CompanyName").Value = _
Request.QueryString("CompanyName")
End If
If cstr(Request.QueryString("CustomerID")) <> "" Then
rs.Fields("CustomerID").Value = Request.QueryString("CustomerID")
End If
' If the QueryString variable has been set
If Request.QueryString("Country").count <> 0 Then
' Update the field with the QueryString value.
rs.Fields("Country").Value = Request.QueryString("Country")
End If
NOTE: The following code assumes that the fields in your Microsoft
Access 97 table have their Required property set to No. If Required is
set to Yes, the update will fail because you are trying to set the
value of a required field to NULL. If the fields in the table have their
AllowZeroLength property set to Yes, you can set the fields equal to a
zero length string.
' If the QueryString variable has been set
If Request.QueryString("Country").count <> 0 Then
' And if the QueryString variable is not a zero length string
If cstr(Request.QueryString("Country")) <> "" Then
' Then update the field with the new data.
rs.Fields("Country").Value = Request.QueryString("Country")
Else
' Otherwise set the value of the field to NULL.
rs.Fields("Country").Value = NULL
' If you are updating a required field, you can use the following
' line of code instead of the one above, as long as the
' AllowZeroLength property of the required field is set to Yes:
'
' rs.Fields("Country").Value = ""
End If
End If
' Repeat the pattern for the remaining fields on the form.
If Request.QueryString("Fax").count <> 0 Then
If cstr(Request.QueryString("Fax")) <> "" Then
rs.Fields("Fax").Value = Request.QueryString("Fax")
Else
rs.Fields("Fax").Value = NULL
End If
End If
If Request.QueryString("Phone").count <> 0 Then
If cstr(Request.QueryString("Phone")) <> "" Then
rs.Fields("Phone").Value = Request.QueryString("Phone")
Else
rs.Fields("Phone").Value = NULL
End If
End If
If Request.QueryString("PostalCode").count <> 0 Then
If cstr(Request.QueryString("PostalCode")) <> "" Then
rs.Fields("PostalCode").Value = _
Request.QueryString("PostalCode")
Else
rs.Fields("PostalCode").Value = NULL
End If
End If
If Request.QueryString("Region").count <> 0 Then
If cstr(Request.QueryString("Region")) <> "" Then
rs.Fields("Region").Value = Request.QueryString("Region")
Else
rs.Fields("Region").Value = NULL
End If
End If
If Request.QueryString("City").count <> 0 Then
If cstr(Request.QueryString("City")) <> "" Then
rs.Fields("City").Value = Request.QueryString("City")
Else
rs.Fields("City").Value = NULL
End If
End If
If Request.QueryString("Address").count <> 0 Then
If cstr(Request.QueryString("Address")) <> "" Then
rs.Fields("Address").Value = Request.QueryString("Address")
Else
rs.Fields("Address").Value = NULL
End If
End If
If Request.QueryString("ContactTitle").count <> 0 Then
If cstr(Request.QueryString("ContactTitle")) <> "" Then
rs.Fields("ContactTitle").Value = _
Request.QueryString("ContactTitle")
Else
rs.Fields("ContactTitle").Value = NULL
End If
End If
If Request.QueryString("ContactName").count <> 0 Then
If cstr(Request.QueryString("ContactName")) <> "" Then
rs.Fields("ContactName").Value = _
Request.QueryString("ContactName")
Else
rs.Fields("ContactName").Value = NULL
End If
End If
If Request.QueryString("CompanyName").count <> 0 Then
If cstr(Request.QueryString("CompanyName")) <> "" Then
rs.Fields("CompanyName").Value = _
Request.QueryString("CompanyName")
Else
rs.Fields("CompanyName").Value = NULL
End If
End If
If Request.QueryString("CustomerID").count <> 0 Then
If cstr(Request.QueryString("CustomerID")) <> "" Then
rs.Fields("CustomerID").Value = _
Request.QueryString("CustomerID")
Else
'CustomerID cannot be blank, so there is no other option
End If
End If
http://<ServerName>/Test/Customers.asp
Additional query words: delete clear remove control empty save
Keywords: kbhowto kbinterop kbprogramming KB166911