i have a file maintenance that will add, edit, delete, etc. data
i have a combobox that autocompletes the text i entered once i typed only one letter. Below is my code for it:
CODE
Private Sub cboAgency_Change()
Dim blnAuto As Boolean
Dim strPart As String, iLoop As Integer, iStart As Integer, strItem As String
If Not blnAuto And CBOAGENCY.Text <> "" Then
iStart = CBOAGENCY.SelStart
strPart = Left$(CBOAGENCY.Text, iStart)
For iLoop = 0 To CBOAGENCY.ListCount - 1
strItem = UCase$(CBOAGENCY.List(iLoop))
If strItem Like UCase$(strPart & "*") And _
strItem <> UCase$(CBOAGENCY.Text) Then
blnAuto = True
CBOAGENCY.SelText = Mid$(CBOAGENCY.List(iLoop), iStart + 1)
CBOAGENCY.SelStart = iStart
CBOAGENCY.SelLength = Len(CBOAGENCY.Text) - iStart
blnAuto = False
Exit For
End If
Next iLoop
End If
End Sub
Private Sub cboAgency_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyBack Or KeyCode = vbKeyDelete Then
blnAuto = True
CBOAGENCY.SelText = ""
blnAuto = False
ElseIf KeyCode = vbKeyReturn Then
cboAgency_LostFocus
CBOAGENCY.SelStart = Len(CBOAGENCY.Text)
CBOAGENCY.SelLength = Len(CBOAGENCY.Text)
End If
End Sub
Private Sub cboAgency_LostFocus()
Dim iLoop As Integer
If CBOAGENCY.Text <> "" Then
For iLoop = 0 To CBOAGENCY.ListCount - 1
If UCase$(CBOAGENCY.List(iLoop)) = UCase$(CBOAGENCY.Text) Then
blnAuto = True
CBOAGENCY.Text = CBOAGENCY.List(iLoop)
blnAuto = False
Exit For
End If
Next iLoop
End If
End Sub
actually, there was no problem with my code for the combobox. but i think this is one of the reasons (maybe) why i am having an error.
i am updating my database with the new data i entered in my combox. Here is my code:
CODE
Private Sub cmdUpdate_Click()
Dim UpdateRec As String
If VerEntry Then
MsgBox "Please fill up the fields you left blank.", vbInformation, "Incomplete information detected..."
EnableFields
Else
UpdateRec = "update tblRepat set LAST_NAME='" & txtLName.Text & "', FIRST_NAME='" & txtFName.Text & "', MIDDLE_NAME='" & txtMName.Text & "', COUNTRY='" & cboCountry.Text & "', POSITION='" & cboPosition.Text & "', AGENCY='" & CBOAGENCY.Text & "' where REPAT_NO=" & Str(Val(txtRepatNo))
Set UpdateRecRS = myConn.Execute(UpdateRec)
MsgBox "The new record has been added succesfully.", vbInformation, "Adding new record..."
cmdSave.Enabled = False
cmdNew.Enabled = True
If cmdNew.Enabled = True Then
disablefields
End If
End If
End Sub
AN error stated that
SYNTAX ERROR IN UPDATE STATEMENT.
what should i change in my codes. pls help.
thanks.