Hello everybody... I`m experiencing a problem... I have a table with 4 fields (user_id, language, grade, rec_id) in my db. Language is part of the primary key, so it cannot by a null value in this field.
As you can see below I`m do not permit this using
VB script. So... If someone will try to insert a null value a warning message comes on the screen, but the action keeps to go on. So I have an error screen coming from Microsoft Access that informs me about the null values... and so.
I would like you to tell me what to do with the
VB script in order to stop the action when "Language field" is empty.
Here is the code of the hole page I use.
<BODY>
<%
'Create the recordset object
Set objRS = Server.CreateObject("ADODB.Recordset")
'Set the SQL string
strSQL = "Select user_id, Language, Grade, rec_id from Languages Where rec_id = " & _
Request.Form("recid")
objRS.Open strSQL, "dsn=My_proj"
%>
<form action=UpdateLanguage2.asp method=post name=frmUpdate>
<input type=hidden name=Action value=Update>
<input type=hidden name=txtID
value=<%=Request.Form("recid")%>>
<table>
<tr>
<td nowrap>Language</td>
<td><input type=text name=txtlanguage size=20
value="<%=objRS("Language")%>">*</td>
<td width=10></td>
<tr>
<td>Grade</td>
<td><select name=txtgrade>
<option value="<%=objRS("Grade")%>" selected> <%=objRS("Grade")%> </option>
<%if objRS("Grade")="Good" then%>
<option value="Pretty good">Pretty good</option>
<option value="Great">Great</option>
<%elseif objRS("Grade")="Pretty good" then%>
<option value="Good">Good</option>
<option value="Great">Great</option>
<%elseif objRS("Grade")="Great" then%>
<option value="Good">Good</option>
<option value="Pretty good">Pretty good</option>
<%
end if
%>
</tr>
<tr>
<td><input type=submit name=btnSubmit value=Submit></td>
</tr>
</table>
</form>
<script language=vbscript>
Sub btnSubmit_OnClick()
If Len(frmupdate.txtlanguage.value) = 0 Then
Alert "You have to insert a Language"
frmupdate.txtlanguage.focus
Exit Sub
End If
Call frmupdate.submit()
End Sub
</script>
<%
'Close and dereference database objects
objRS.Close
Set objRS = Nothing
%>
</BODY>