Solved

Syntex error when Set rs = CurrentDb.OpenRecordset in access form

Posted on 2010-11-15
3
774 Views
Last Modified: 2012-05-10
Hi I have a form.
I have combo field IsT1 and a Text field Email1.
Based on what they selet on IsT1, I like to populate Email1  the email field for the full name from table tblEmployees.
On the On After update event I have the following code

 Private Sub IsT1_AfterUpdate()
Dim db As DAO.Database
 Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset("select EmailA from tblEmployees where Fullname = " & Me.IsT1)
    Me.Email1 = rs!EmailA
End Sub

I get the following error

Syntex eror(missing opertor) in query expression Fullname = displays name '
Please advice what I'm doing wrong in my syntex
0
Comment
Question by:Sivasan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 34138411
try this:

Set rs = CurrentDb.OpenRecordset("select EmailA from tblEmployees where Fullname = " & Chr(34) & Me.IsT1 & Chr(34) )
    Me.Email1 = rs!EmailA
End Sub

mx
0
 

Author Comment

by:Sivasan
ID: 34138437
Great you are awesome!! Thankss a lott
0
 
LVL 75
ID: 34138465
Because Me.IsT1 is a Text value (String), it needs to be surrounded by Double Quotes in Criteria as such.  Chr(34) is a double quote.   Dates must be surrounded by the # sign.  Numeric w/b the way you initially had it.

mx
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question