Why does my code return the value "False"?

In the else part of this procedure, the sql variable returns the string "False" upon debugging and running.  Why?

Private Sub mnuSave_Click()

Dim sql As String

If ValidCustomer Then
    'if new customer
    If txtCustID = "" Then
        sql = "INSERT INTO Customer (CustTitle, CustSurname, CustHouseNo, CustAdd1, CustAdd2, " & _
        "CustTown, CustCounty, CustPostcode, CustHomeTel, CustWorkTel, CustWorkExt, CustMobileTel)" & _
        " VALUES ('" & txtTitle & "', '" & txtSurname & "', " & txtHouseNo & ", '" & txtAddress(0) & _
        "', '" & txtAddress(1) & "', '" & txtTown & "', '" & txtCounty & "', '" & txtPostcode & _
        "', '" & txtHomeTel & "', '" & txtWorkTel & "', '" & txtExtension & "', '" & txtMobile & "')"
        db.Execute sql
    Else
        sql = "UPDATE Customer SET CustTitle = '" & txtTitle & "', CustSurname = '" & txtSurname & _
        "', CustHouseNo = " & txtHouseNo & ", CustAdd1 = '" & txtAddress(0) & "', custadd2 = '" & _
        txtAddress(1) & "', CustTown = '" & txtTown & "', CustCounty = '" & txtCounty & _
        "', CustPostcode = '" & txtPostcode = "', CustHomeTel = '" & txtHomeTel & _
        "', CustWorkTel = '" & txtWorkTel & "', CustWorkExt = '" & txtExtension & _
        "', CustMobileTel = '" & txtMobile & "' WHERE CustID = " & txtCustID
        db.Execute sql
    End If
End If
       
End Sub
andcuAsked:
Who is Participating?
 
Jeremy_DConnect With a Mentor Commented:
The '=' behind '& txtPostcode' should be a '&'. At this point it's not a string concatenation, but a logical expression I would not care to decypher ;-)

Cheers,
Jeremy
0
 
Jeremy_DCommented:
The reason it returns the string "False" is of course because VB will allow you to do almost any horibly wrong assignment without bothering about warning you during compile. In this case it's the inplicit conversion from Boolean type to String type.
0
 
andcuAuthor Commented:
I thought it must be something like this but I couldn't see the error.


WELL DONE THAT MAN!!
0
All Courses

From novice to tech pro — start learning today.