This key record will have only char(255) in the comments field, nothing
else.
So, I will not need to traverse the entire memo field. With that in
mind
shouldn't the DCount solution work - you are right, DCount should be
faster
than InStr so that is my preference, but I can't figure out why the
DCount
solution does not work.
:
Hi Rod,
it is looking for the field EQUAL to chr(255), not containing "255"...
you will need to change the condition in that case -- and this will
take
even longer to find:
"InStr([COMMENTS],'hold_the_alt_key_dn_and_type_255') > 0"
or, if you want to find either condition:
"InStr([COMMENTS],'hold_the_alt_key_dn_and_type_255') > 0 OR
[COMMENTS]
= '" & Chr(255) & "'"
InStr is in string -- returns the position in the first string that
the
second string was found
Warm Regards,
Crystal
remote programming and training
Video Tutorials on YouTube!
http://www.youtube.com/user/LearnAccessByCrystal
Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace
*
have an awesome day
*
Rod wrote:
I have
Private Sub Form_Open(Cancel As Integer)
If DCount("*", "[tblCandidates]", "[COMMENTS] = '" & Chr(255) &
"'") = 0
Then
Cancel = True
End If
End Sub
and record 78076 has [COMMENTS] = hold_the_alt_key_dn_and_type_255.
It
never loads the form, so the DCount must be 0; it should be 1 and
therefore
load.
:
Hi Rod,
you can do something like this on the form OPEN event:
'~~~~~~~~~~~~
if dcount("*","[Tablename]" _
,"[comment] = '" & chr(255) & "'") = 0 then
Cancel = true
end if
'~~~~~~~~~~~~
I would suggest, however, that you add an index to your comment
field to
make this faster. If it is a memo field, you cannot. I would also
recommend you use another field (or another method to determine
permission) as it will be slow to search a long comment field...
you can also set up a query to return records where this condition
is
true and count the query records instead of the table records for it
to
be faster
Warm Regards,
Crystal
remote programming and training
Video Tutorials on YouTube!
http://www.youtube.com/user/LearnAccessByCrystal
Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace
*
have an awesome day
*
Rod wrote:
Hello,
I would like to do something like this when the form load is
attempted:
1) Check to see if any of the records [Comment] fields equal the
special
invisible character 255.
2) If found then load and continue normally.
3) If not found I want to halt with no error - just terminate.
Thanks for your help!