Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Argument are of wrong type or are out of acceptable range

Status
Not open for further replies.

patelr

Programmer
Oct 10, 2002
17
CH
I am trying to use VB6 and ADODB to maintain Access database file.

I can add first record using the VB code shown below, However, if I use the same logic next time around I get following error: Argument are of wrong type, are out of acceptable range, or are in conflict with one another.

Any idea? What have I missed?

Here is the code snippet

' Open connection
Set Cn = New ADODB.Connection
strcn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Trim(App.Path) & "\employees.mdb"

Cnxn.Open strCn

' Open recordset to enable changes
Set rstEmployees = New ADODB.Recordset
strSQLEmployees = "SELECT * FROM Employee"
rstEmployees.Open strSQLEmployees, Cnxn, adOpenKeyset, adLockOptimistic, adCmdText

'set Criteria
criteria = "First Name='" & UCase(fname)) & "'"
rstEmployees.Find (criteria) ' Find first occurrence.

' save changes or add record
If Not rstOverlay.EOF Then
rstEmployees("First Name")= "XYZ123"
rstEmployees("Last Name") = "ZXY456"
rstEmployees.Update
Else
rstEmployees.addnew
rstEmployees("First Name") = "XYZ"
rstEmployees("Last Name") = "ZXY456"
rstEmployees.Update

End If

Thanks for help in advance.
 
error occurs when .Find method is executed..
 
A field name containing spaces needs to be in brackets

criteria = "[First Name]='" & UCase(fname)) & "'"
 
Also, that convention isn't supported by every SQL-based DBMS, so if you're thinking about ever migrating away from Access, you might consider removing the space.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top