I need to make sure that I am on a different record than I just was
on, in a DAO recordset.
code fragment:
1. strFind = "thisSource = " & tripID & " AND thisTrip = " & tripID
2. rs.FindFirst (strFind)
3. If Not rs.NoMatch Then
4. strBookmark = rs.Bookmark
5. rs.MoveFirst
6. If rs.Bookmark = strBookmark Then rs.MoveNext
7. ...and so on
it wont compile because of a type mismatch, highlighting the equal
sign on line 6; not on line 4.
I have cast my bookmark variable as string, long, variant, with the
same result. I can probably do this another way, but I want to know
why it isn't working this way, first. -tc 11 4267
From memory, bookmarks are case-sensitive variants.
Try declaring:
Dim varBookmark As Variant
Then at line 4:
varBookmark = rs.Bookmark
Then at line 6:
If StrComp(rs.Book mark, varBookmark, vbBinaryCompare ) = 0 ...
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Tom Clavel" <to*******@oura ynet.comwrote in message
news:11******** **************@ e65g2000hsc.goo glegroups.com.. .
>I need to make sure that I am on a different record than I just was
on, in a DAO recordset.
code fragment:
1. strFind = "thisSource = " & tripID & " AND thisTrip = " & tripID
2. rs.FindFirst (strFind)
3. If Not rs.NoMatch Then
4. strBookmark = rs.Bookmark
5. rs.MoveFirst
6. If rs.Bookmark = strBookmark Then rs.MoveNext
7. ...and so on
it wont compile because of a type mismatch, highlighting the equal
sign on line 6; not on line 4.
I have cast my bookmark variable as string, long, variant, with the
same result. I can probably do this another way, but I want to know
why it isn't working this way, first. -tc
Thanks. It works just right. -tc
On Apr 22, 10:07 pm, "Allen Browne" <AllenBro...@Se eSig.Invalid>
wrote:
From memory, bookmarks are case-sensitive variants.
Try declaring:
Dim varBookmark As Variant
Then at line 4:
varBookmark = rs.Bookmark
Then at line 6:
If StrComp(rs.Book mark, varBookmark, vbBinaryCompare ) = 0 ...
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Tom Clavel" <tomcla...@oura ynet.comwrote in message
news:11******** **************@ e65g2000hsc.goo glegroups.com.. .
I need to make sure that I am on a different record than I just was
on, in a DAO recordset.
code fragment:
1. strFind = "thisSource = " & tripID & " AND thisTrip = " & tripID
2. rs.FindFirst (strFind)
3. If Not rs.NoMatch Then
4. strBookmark = rs.Bookmark
5. rs.MoveFirst
6. If rs.Bookmark = strBookmark Then rs.MoveNext
7. ...and so on
it wont compile because of a type mismatch, highlighting the equal
sign on line 6; not on line 4.
I have cast my bookmark variable as string, long, variant, with the
same result. I can probably do this another way, but I want to know
why it isn't working this way, first. -tc
Tom Clavel <to*******@oura ynet.comwrote in
news:11******** **************@ e65g2000hsc.goo glegroups.com:
I need to make sure that I am on a different record than I just
was on, in a DAO recordset.
code fragment:
1. strFind = "thisSource = " & tripID & " AND thisTrip = " &
tripID 2. rs.FindFirst (strFind)
3. If Not rs.NoMatch Then
4. strBookmark = rs.Bookmark
5. rs.MoveFirst
6. If rs.Bookmark = strBookmark Then rs.MoveNext
7. ...and so on
it wont compile because of a type mismatch, highlighting the equal
sign on line 6; not on line 4.
I have cast my bookmark variable as string, long, variant, with
the same result. I can probably do this another way, but I want
to know why it isn't working this way, first.
Why are you storing the bookmark? Are you going to keep track of
more than one bookmark at a time?
Wouldn't what you are doing make much more sense testing real values
in the records, instead of the bookmarks?
I have never once stored a bookmark in a variable, so don't quite
see the point. It's data that is much too volatile to be stored,
seems to me.
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
On Apr 23, 10:16 am, "David W. Fenton" <XXXuse...@dfen ton.com.invalid >
wrote:
Tom Clavel <tomcla...@oura ynet.comwrote innews:11****** *************** *@e65g2000hsc.g ooglegroups.com :
I need to make sure that I am on a different record than I just
was on, in a DAO recordset.
code fragment:
1. strFind = "thisSource = " & tripID & " AND thisTrip = " &
tripID 2. rs.FindFirst (strFind)
3. If Not rs.NoMatch Then
4. strBookmark = rs.Bookmark
5. rs.MoveFirst
6. If rs.Bookmark = strBookmark Then rs.MoveNext
7. ...and so on
it wont compile because of a type mismatch, highlighting the equal
sign on line 6; not on line 4.
I have cast my bookmark variable as string, long, variant, with
the same result. I can probably do this another way, but I want
to know why it isn't working this way, first.
Why are you storing the bookmark? Are you going to keep track of
more than one bookmark at a time?
Wouldn't what you are doing make much more sense testing real values
in the records, instead of the bookmarks?
I have never once stored a bookmark in a variable, so don't quite
see the point. It's data that is much too volatile to be stored,
seems to me.
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/- Hide quoted text -
- Show quoted text -
Bookmarks are strings in case anyone wants to know. I've used them a
lot to mark records or to position to a specific record in a form. If
I remember correctly (always an issue!), one of the form wizards uses
bookmarks in the generated code.
-- Larry Engles
Access developer since day 1 of Access 1.0
<en****@ridesof t.comreplied in message
news:11******** *************@o 40g2000prh.goog legroups.com...
Bookmarks are strings in case anyone wants to know.
Larry, that's not strictly correct. Bookmarks are a variant array of bytes.
You can make them display like strings, but attempting to use them as
strings can fail. That's exactly what the original poster in this thread
discovered.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
On Apr 23, 9:54 pm, "Allen Browne" <AllenBro...@Se eSig.Invalidwro te:
<eng...@ridesof t.comreplied in messagenews:11* *************** *****@o40g2000p rh.googlegroups .com...
Bookmarks are strings in case anyone wants to know.
Larry, that's not strictly correct. Bookmarks are a variant array of bytes.
You can make them display like strings, but attempting to use them as
strings can fail. That's exactly what the original poster in this thread
discovered.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
I did not know that. I've always declared them as strings and have
never had a problem. I see (now) that help shows them being used as
variants. If I recall, I experimented (we're talking Access 1.1 or
2.0 probably) to find how to declare them.
It's not clear to me how an "array of bytes" differs from a string.
Is it a zero terminator?
Thanks,
-- Larry Engles
Access developer since day 1 of Access 1.0
It is possible to visualize a string as an array of bytes. Some languages
(e.g. Pascal) do that.
However, strings may not be bytes, e.g. Unicode. And strings in some
languagues are null terminted, so the first chr(0) in the string would be
interpreted as the end of the string.
In VBA, strings are not arrays:
? IsArray("Hello" )
whereas bookmarks are:
? IsArray(Forms(0 ).Bookmark))
(assuming the first form is open, bound, and not at a new record.)
Treating a bookmark as as string wrongly reports it as 2 characters long:
? Len(Forms(0).Bo okmark) 'WRONG!
In fact, it is an array of 4 bytes:
Sub ExamineBM()
Dim varBM As Variant
Dim i As Long
Dim bt As Byte
varBM = Forms(0).Bookma rk
For i = LBound(varBM) To UBound(varBM)
bt = varBM(i)
Debug.Print bt
Next
End Sub
A bookmark is therefore more like IP address than a string.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
<en****@ridesof t.comwrote in message
news:11******** **************@ r30g2000prh.goo glegroups.com.. .
On Apr 23, 9:54 pm, "Allen Browne" <AllenBro...@Se eSig.Invalidwro te:
><eng...@rideso ft.comreplied in messagenews:11 *************** ******@o40g2000 prh.googlegroup s.com...
Bookmarks are strings in case anyone wants to know.
Larry, that's not strictly correct. Bookmarks are a variant array of bytes.
You can make them display like strings, but attempting to use them as strings can fail. That's exactly what the original poster in this thread discovered.
-- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users -http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org.
I did not know that. I've always declared them as strings and have
never had a problem. I see (now) that help shows them being used as
variants. If I recall, I experimented (we're talking Access 1.1 or
2.0 probably) to find how to declare them.
It's not clear to me how an "array of bytes" differs from a string.
Is it a zero terminator?
Thanks,
-- Larry Engles
Access developer since day 1 of Access 1.0
en****@ridesoft .com wrote in
news:11******** *************@o 40g2000prh.goog legroups.com:
If
I remember correctly (always an issue!), one of the form wizards
uses bookmarks in the generated code.
It uses them but does not store them. I use them just the way the
wizard does, for bookmark navigation, but I would never store a
bookmark value.
I can't come up with a reason for doing so.
If I want to navigate to a particular record after departing it to
go to another, I store the PK of the record and navigate to that.
That insures that a requery in between won't invalidate the value
I'm storing.
Can anyone come up with a scenario where storing a bookmark value is
the only way to accomplish the task?
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
David, I almost never store a bookmark in a variable either, but I have used
this occassionally:
Dim varBM As Variant
varBM = rs.Bookmark
'move the recordset somewhere else, e.g. to read a value
rs.Bookmark = varBM
Using a bookmark to return to the record is (reportedly) the most efficient
approach - certainly faster than FindFirst.
And Access does store maintain some bookmarks in memory too, such as
LastModified.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"David W. Fenton" <XX*******@dfen ton.com.invalid wrote in message
news:Xn******** *************** ***********@127 .0.0.1...
en****@ridesoft .com wrote in
news:11******** *************@o 40g2000prh.goog legroups.com:
>If I remember correctly (always an issue!), one of the form wizards uses bookmarks in the generated code.
It uses them but does not store them. I use them just the way the
wizard does, for bookmark navigation, but I would never store a
bookmark value.
I can't come up with a reason for doing so.
If I want to navigate to a particular record after departing it to
go to another, I store the PK of the record and navigate to that.
That insures that a requery in between won't invalidate the value
I'm storing.
Can anyone come up with a scenario where storing a bookmark value is
the only way to accomplish the task?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stephen Briley |
last post by:
For some reason, my posts are scrubbed as attachments.
Lets hope that sending from the yahoo account works.
I'm new to Python and I'm trying to do some database
work with MS Access, but I can't seem to get around a
"datatype mismatch error". Here's an example table
that I'm working with...
ID name dept
1 steve acct
|
by: Steve Briley |
last post by:
I'm new to Python and I'm trying to do some database work with MS Access, but I can't seem to get around a "datatype mismatch error". Here's an example table that I'm working with...
ID name dept
1 steve acct
|
by: Ken |
last post by:
I wrote a function to use in queries that takes a date and adds or
subtracts a certain length time and then returns the new value. There
are times when my function needs to return Null values.
Function DateCalc (blah...) As Variant
Do Stuff...
If Not IsNull(varNewDate) Then
DateCalc = varNewDate
End If
End Function
|
by: JingleBEV |
last post by:
Hi,
Iam coding data access application with database object and recordset.
Here' s my code
'------------------------------------------------------------------
Private Function CreateRecordSet() As Boolean
Dim db As Database
Dim rs As Recordset
Set db = DBEngine.Workspaces(0).OpenDatabase(txtDBpath)
sql = "SELECT * FROM TblMembers"
|
by: rn5a |
last post by:
I am inserting records in a MS-Access database table. The data type of
one of the columns named *OrderDate* in the DB table is Date/Time.
This is the SQL query I am using to insert the records in the Access
DB table:
===============================
strSQL = "INSERT INTO Cart (CartID, ProductID, Quantity, Total,
OrderDate) VALUES (CID, PID, Qty, TotalAmt, ODate)"
oleDbCmd = New OleDbCommand(strSQL, oleDbConn)
| |
by: chirag1989 |
last post by:
I m havin an error of datatype mismatch
actual here i m askin user to input the code in text box and then searchin the
record havin that code in database
the problem is the code field Bnum is of number datatype
so its showin me this error
Microsoft JET Database Engine (0x80040E07)
Data type mismatch in criteria expression.
/library/12updbook1.asp, line 128
|
by: Snoopy33 |
last post by:
I have a query that builds a date from a text field with the date
imput as yyyymmdd in the query, so i have to piece it together in my
expression as follows:
exp: FormatNumber(DateDiff("d",DateSerial(Left(,
4),Left(Right(,4),2),Right(,2)),Now())))
if i don't use a criteria, it works fine. when i try to use the
criteria <7 is when i get the error. It will show the correct records
|
by: rscheinberg |
last post by:
I am working in Access 2007 attempting to grab 2 characters from a text field named ProjectNumber. After determining what 2 digits to add in front to make it a year, I need to do that. I have done that in the code below to create a value for "intPN". I then need that value to become a number so that I can compare it to a range of years (1983-1987). The code below returns the 4 character year as intended. But I get a Datatype mismatch error...
|
by: rscheinberg |
last post by:
I am working in Access 2007 attempting to grab 2 characters from a text field named ProjectNumber. After determining what 2 digits to add in front to make it a year, I need to do that. I have done that in the code below to create a value for "intPN". I then need that value to become a number so that I can compare it to a range of years (1983-1987). The code below returns the 4 character year as intended. But I get a Datatype mismatch in criteria...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |