Senin, 16 September 2013

[MS_AccessPros] FindFirst method syntax

 

 

Hello

The syntax in my FindFirst method (in orange color) generated this error:

Error 3070 (the Microsoft Access database engine does not recognize 'a101' as a valid field name or expression)

 

I thought it's correct as the other 2 (color in blue).  If I remember correctly, I think I have seen it somewhere, either 1 is correct. Am I wrong?

 

Phucon

 

Private Sub cmdSave_Click()

On Error GoTo ErrorHandler

 

If IsNull(Me.txtsAcctID) Or IsNull(Me.txtsName) Then

     MsgBox "Acct ID and Name cannot be left blank."

     GoTo ExitProcedure

End If

 

 Set db = CurrentDb

Set rs = db.OpenRecordset("tblPled", dbOpenDynaset)

 

'rs.FindFirst "AcctId = " &  Chr$(34) & Me.txtsAcctID & Chr$(34)

 

 rs.FindFirst "AcctId = " & "' & (Me.txtsAcctID) & '"

 

 ' rs.FindFirst "AcctId = " & "" & Me.txtsAcctID & ""

 

     With rs

          If .NoMatch Then

               .AddNew

                    !sAcctID = Me.txtsAcctID

                    !sName = Me.txtsName                        

                .Update

                .Close

           Else

               MsgBox "Cannot save record. This Acct ID already exist.", vbExclamation, "Invalid Account ID"

               GoTo ExitProcedure

          End If

     End With

ExitProcedure:

     TempVars.Remove "DateIsBlank"

   Exit Sub

 

ErrorHandler:

           MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdSave_Click"

          Resume ExitProcedure

End Sub

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
.

__,_._,___

Tidak ada komentar:

Posting Komentar