Can someone tell me why this isn't working? I'm trying to use a bookmark to
go to a particular record in a recordset. The recordset is from an Access
97 database. Here's the code:
Dim sConn As String
Set cnWebOrder = New ADODB.Connection
If sDBPath = "" Then sDBPath = "c:\documents and settings\my
documents\web orders\weborders.mdb"
sConn = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security
Info=False;Data Source=" & sDBPath
With cnWebOrder
.ConnectionString = sConn
.CursorLocation = adUseClient
.Open
End With
Dim sSQL As String
sSQL = "Select * from tblweborders" & vbCrLf
sSQL = sSQL & "WHERE (((tblweborders.Name) Like " & "'%" & sCustName &
"%'));"
With rsWebOrder
.ActiveConnection = cnWebOrder
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open sSQL
End With
With rsWebOrder
.MoveFirst
.MoveLast
.MoveFirst
End With
'The following in a double click event in a grid control:
Dim vBkMk As Variant
rsWebOrder.MoveFirst
vBkMk = CVar(fgBrowse.TextMatrix(fgBrowse.Row,
fgBrowse.ColIndex("Bookmark")))
rsWebOrder.Bookmark = vBkMk
The line rsWebOrder.Bookmark = vBkMk throws the error "Run time error 3001.
Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another."
I've stepped through the code and vBkMk evaluates to a valid bookmark, so I
can't think why this isn't working. If anyone can tell me where I'm going
wrong, I would appriciate it. Thanks in advance
Jim
Paul Clement - 19 Jul 2007 16:10 GMT
¤ Can someone tell me why this isn't working? I'm trying to use a bookmark to
¤ go to a particular record in a recordset. The recordset is from an Access
¤ 97 database. Here's the code:
¤
¤ Dim sConn As String
¤
¤ Set cnWebOrder = New ADODB.Connection
¤
¤
¤ If sDBPath = "" Then sDBPath = "c:\documents and settings\my
¤ documents\web orders\weborders.mdb"
¤
¤ sConn = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security
¤ Info=False;Data Source=" & sDBPath
¤
¤ With cnWebOrder
¤ .ConnectionString = sConn
¤ .CursorLocation = adUseClient
¤ .Open
¤ End With
¤
¤ Dim sSQL As String
¤
¤ sSQL = "Select * from tblweborders" & vbCrLf
¤ sSQL = sSQL & "WHERE (((tblweborders.Name) Like " & "'%" & sCustName &
¤ "%'));"
¤
¤ With rsWebOrder
¤ .ActiveConnection = cnWebOrder
¤ .CursorLocation = adUseClient
¤ .CursorType = adOpenStatic
¤ .LockType = adLockOptimistic
¤ .Open sSQL
¤ End With
¤
¤ With rsWebOrder
¤ .MoveFirst
¤ .MoveLast
¤ .MoveFirst
¤ End With
¤ 'The following in a double click event in a grid control:
¤
¤ Dim vBkMk As Variant
¤
¤ rsWebOrder.MoveFirst
¤
¤ vBkMk = CVar(fgBrowse.TextMatrix(fgBrowse.Row,
¤ fgBrowse.ColIndex("Bookmark")))
¤
¤ rsWebOrder.Bookmark = vBkMk
¤
¤ The line rsWebOrder.Bookmark = vBkMk throws the error "Run time error 3001.
¤ Arguments are of the wrong type, are out of acceptable range, or are in
¤ conflict with one another."
¤
¤ I've stepped through the code and vBkMk evaluates to a valid bookmark, so I
¤ can't think why this isn't working. If anyone can tell me where I'm going
¤ wrong, I would appriciate it. Thanks in advance
Are you sure that the Bookmark in the FlexGrid is the same as that for a Recordset?
Paul
~~~~
Microsoft MVP (Visual Basic)