473,395 Members | 1,583 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,395 software developers and data experts.

Go to a Single Record. Dlookup or SQL Recordset?

When I use Dlookup. I am only able to return a single value and
therefore cannot seem to assign a single records (3-field values) to
(3-Variables). I noticed that I can get the 3-field values, but it is
returned as a single string, probably requiring parsing. Not Desirable!
Maybe I need Dlookup to get a unique key value, and then look again
for the record somehow? But, I understand that Dlookup has issues (ie
performance and reliability).

I am looking for a fast / reliable way of looking up a single record in
code, without affect my currently displayed record, and then fill my
variables. I read that a SQL /RecordSet marriage
of some sort is the way to go, but am lost on concept and syntax. Any
suggestions???

Greg

Jan 26 '07 #1
6 10183
dim rs as recordset
set rs = currentdb.opensrecordset("SELECT * FROM yourtablename WHERE
yourcriteria here")
something1 = rs!oneofyourfields
something2 = rs!anotheroneofyourfields
' do stuff
' close the recordset
rs.close
set rs = nothing

Cheers,
Jason Lepack

On Jan 26, 1:02 pm, "ApexD...@gmail.com" <ApexD...@gmail.comwrote:
When I use Dlookup. I am only able to return a single value and
therefore cannot seem to assign a single records (3-field values) to
(3-Variables). I noticed that I can get the 3-field values, but it is
returned as a single string, probably requiring parsing. Not Desirable!
Maybe I need Dlookup to get a unique key value, and then look again
for the record somehow? But, I understand that Dlookup has issues (ie
performance and reliability).

I am looking for a fast / reliable way of looking up a single record in
code, without affect my currently displayed record, and then fill my
variables. I read that a SQL /RecordSet marriage
of some sort is the way to go, but am lost on concept and syntax. Any
suggestions???

Greg
Jan 26 '07 #2
Thanks Jason

I tried the following code, but am getting a error "Missing operator in
query expression" on the Set rs line of my code, but can't figure it
out. Possible delimiter issue???

Dim rs As Recordset
Dim strSQL As String
strSQL = "SELECT * FROM [TL-ZIPCODE] WHERE ZIP = " & txtZIP
Set rs = CurrentDb.OpenRecordset(strSQL)
MsgBox rs!CITY
MsgBox rs!LNAME
' do stuff
' close the recordset
rs.Close
Set rs = Nothing

Any ideas???

Jan 26 '07 #3
i think you might have to put some more " " " around your txtzip and a me

strSQL = "SELECT * FROM [TL-ZIPCODE] WHERE ZIP = " & me.txtZIP & ""
OR
strSQL = "SELECT * FROM [TL-ZIPCODE] WHERE ZIP = """ & me.txtZIP & """"

i'm still half asleep, but hope this helps you

Ap******@gmail.com wrote:
>Thanks Jason

I tried the following code, but am getting a error "Missing operator in
query expression" on the Set rs line of my code, but can't figure it
out. Possible delimiter issue???

Dim rs As Recordset
Dim strSQL As String
strSQL = "SELECT * FROM [TL-ZIPCODE] WHERE ZIP = " & txtZIP
Set rs = CurrentDb.OpenRecordset(strSQL)
MsgBox rs!CITY
MsgBox rs!LNAME
' do stuff
' close the recordset
rs.Close
Set rs = Nothing

Any ideas???
--
Regan,
Paeroa
World famous in New Zealand

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200701/1

Jan 26 '07 #4
I suspect that the field ZIP is a text field. Therefore you will need
to add "'" (which is " ' " without the spaces) before and after the
txtZip.

The new line will be:
strSQL = "SELECT * FROM [TL-ZIPCODE] WHERE ZIP = "'" & txtZIP & "'"

Cheers,
Jason Lepack

On Jan 26, 3:02 pm, "ApexD...@gmail.com" <ApexD...@gmail.comwrote:
Thanks Jason

I tried the following code, but am getting a error "Missing operator in
query expression" on the Set rs line of my code, but can't figure it
out. Possible delimiter issue???

Dim rs As Recordset
Dim strSQL As String
strSQL = "SELECT * FROM [TL-ZIPCODE] WHERE ZIP = " & txtZIP
Set rs = CurrentDb.OpenRecordset(strSQL)
MsgBox rs!CITY
MsgBox rs!LNAME
' do stuff
' close the recordset
rs.Close
Set rs = Nothing

Any ideas???
Jan 26 '07 #5

Thanks Regan

strSQL = "SELECT * FROM [TL-ZIPCODE] WHERE ZIP = """ & Left(txtZIP, 5)
& """"

This solved it. I need to study Quote Placement more!
I also needed to refine txtZIP to the five initial chars.

ThankYouALL
Greg

Jan 26 '07 #6
Thanks Jason

Greg

Jan 27 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ken Fine | last post by:
Suppose I've built a recordset. I want some code to run for each record in the recordset in a "loop." In ASP VBScript, how would you express the following: For each in next The only...
1
by: Stewart Graefner | last post by:
I have been unable to locate anywhere the answer to my problem. I would like to be able to download/import a single record. This record is stored in many different related (one to one) tables. I...
2
by: Harold | last post by:
Sat I have a customers table with the fields CustomerID and Customer and I use the recordset.addnew method to add a new record to the table. What is the best way to get the CustomerID of the new...
3
by: Peter Morris [Droopy Eyes Software] | last post by:
Hi all When I bind to multiple records I use a DataList. This allows the web-designer to add code like <%#DataBinder.Eval(Container.DataItem, "Name")%> Whenever I want to retrieve a single...
0
by: Andy | last post by:
Hi All. I'm working for a company that has set out a guideline for retrieving data from a database. Nobody can explain to me the reason for the following. When retrieving a set of records...
6
by: zoro | last post by:
Hi, I am looking for the recommended way to retrieve several values from a single record, i.e. a typical lookup scenario. An example would be a query that needs to retrieve user_name, user_addres,...
22
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
6
by: Aussie Rules | last post by:
Hi, In all my coding to date, i have been dealing with multiple results in my dataset, looping through them with SqlDataAdapterContactProfile.Fill(contact, "Profile") For Each pRow In...
2
by: jamieda | last post by:
I have a multiple items form displaying the contents of a table. It has a primary key and the records are ordered by this. I want to be able to manually select a record in the form and then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
agi2029
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,...

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.