473,320 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Embedding Left( ) into FindFirst criteria...

patjones
931 Expert 512MB
This is not a question, but rather an informational post about something I just solved. My issue was that I'm trying to use

Expand|Select|Wrap|Line Numbers
  1. rst.FindFirst (str1 & " = '" & txtLastNameSearch.Value & "'")
  2.  
My goal was to search through a table with a field fldNameLast, but only compare the leftmost int1 characters in this field to my text box value (txtLastNameSearch.Value). So originally I tried something like

Expand|Select|Wrap|Line Numbers
  1.  str1 = "Left([fldNameLast],int1)" 
But the VB compiler complained about the use of int1 (which is set earlier in the code). After playing around with it for a while, I settled on

Expand|Select|Wrap|Line Numbers
  1.  str1 = "Left([fldNameLast]," & int1 & ")"
And this works very well, at least for all the values of txtLastNameSearch.Value that I've tried so far. Seems like the main rule is to keep variables outside the quotes...
Nov 14 '07 #1
1 1537
Rabbit
12,516 Expert Mod 8TB
Thanks for sharing. What you ran into was a variable scope issue. Not all forms and functions can see every other forms' and functions' variables, which can be confusing to the uninitiated. Hopefully this will help other potential readers with problems.
Nov 14 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Daniel Chartier | last post by:
Hello. I have a question concerning variable criteria for queries and reading forms. Let's say that I have a table with 2 fields and 10 records. One of the fields can have two different...
19
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main...
1
by: cnlai | last post by:
Snippets -------- Dim mydb As Database, myset As DAO.Recordset Set mydb = CurrentDb Set myset = mydb.OpenRecordset("abc") myset.FindFirst (" = 'S02'") '<< problem here Reference: MS DAO...
1
by: Mike MacSween | last post by:
rstStuAddr.MoveFirst rstStuAddr.FindFirst "CountryID = 168 AND Left(CLPostCode,4) <> 'BFPO'" CountryID and CLPostCode are names of fields in rstStuAddr It works. But doesn't look like it...
2
by: Matthew | last post by:
Hey , I have built a query which takes values from unbounded fields on a form, and it all works except for one thing. I have a few fields in my query that are dates. I also have a start and...
2
by: tricard | last post by:
Good day all, I have a large outer joined query that I want to have some criteria. The select query is gathering all part numbers from tblPartNumbers, left joining to tblPartNumberVendor (since...
5
by: perryche | last post by:
I am not sure if I am asking the right question in the subject here. But, here is my problem. I have 5tables/queries with various data like below. Table1: CustomerID1, Field1, Field2 Table2:...
0
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:...
17
by: sharsy | last post by:
Hello guys, I would like some help in generating query criteria that will identify credit cards that have expired on an access database. The specific Field is formatted with a Data Type of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.