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

Record selection based on a conditional

jimleon
74
Hello All

I am trying to select a record to edit using the following commands

query = "select * from companies where name=" & Forms![Main Details]![CO_NAME]

Set record = dbbooking.OpenRecordset(query)

Forms![Main Details]![CO_NAME] is pointing to 'dummy co'

but i get this error when attempting to select the record

Syntax error (missing operator) in query expression 'name=dummy co'

I have tried putting companies and name in square brackets but it doesn't affect it!

Any clues out there?

Many thanks in advance
Apr 25 '07 #1
2 1188
Hello All

I am trying to select a record to edit using the following commands

query = "select * from companies where name=" & Forms![Main Details]![CO_NAME]

Set record = dbbooking.OpenRecordset(query)

Forms![Main Details]![CO_NAME] is pointing to 'dummy co'

but i get this error when attempting to select the record

Syntax error (missing operator) in query expression 'name=dummy co'

I have tried putting companies and name in square brackets but it doesn't affect it!

Any clues out there?

Many thanks in advance

First I think we should know the format of the field "Name" in the table "companies". If it's a text so your query should be :
Expand|Select|Wrap|Line Numbers
  1. query= "select * from companies where name='" & Forms![Main Details]![CO_NAME] & "'"
You just have to add a single quote after (name=) and another one in the end of the query. so it's : Double quote, single quote, double quote (" ' ") without any space.
Apr 25 '07 #2
jimleon
74
Cheers, that worked a treat!


First I think we should know the format of the field "Name" in the table "companies". If it's a text so your query should be :
Expand|Select|Wrap|Line Numbers
  1. query= "select * from companies where name='" & Forms![Main Details]![CO_NAME] & "'"
You just have to add a single quote after (name=) and another one in the end of the query. so it's : Double quote, single quote, double quote (" ' ") without any space.
Apr 25 '07 #3

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

Similar topics

2
by: Terry | last post by:
I have cerated a Form, ExamsFrm, which is used to input details of exams taken at several Centres. It dosplays details from StudentTbl and has a SubForm which displays details from ExamsTble. I...
4
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button wizard (result: DoCmd.GoToRecord , , acNext). I...
3
by: Mark | last post by:
Hi there, I have a subform, set as a continuous form. When a user selects a particular record in that subform, how can I make that particular record stand out (color or font change, size, etc) from...
0
by: Tony Williams | last post by:
I have a database with three tables as follows Table 1=Documents Table 2= Groups On a form based on Table 1 is a continuous subfrom that has a combo box based on Table 2 When the user makes a...
0
by: uthooker | last post by:
I have an Access form with some combo boxes in the Form Header that are enabled/disabled using conditional formatting based on the setting in a checkbox also in the Header (Combo box = Enabled by...
1
by: jmarcrum | last post by:
Hello all! i have a “monitor-type” program, where my program recognizes my defined "commands”, and executes the given command, or produces an error message that says “unrecognized command”. After...
15
beacon
by: beacon | last post by:
Hi everybody, Using Access 2003. I'm trying to dynamically set the record source for the current form and set the control source for a text box to input data to one of three tables. I have a...
2
by: lhsiber | last post by:
I am new to access and am having a problem with filtering. Here is a little bit of my setup: I have a main form that has a listbox so that users can choose one or many groups in which to display...
0
by: solargovind | last post by:
Hello, I have few problem with Dlookup condition. I need to retrieve next record or previous record based on certain condition. The conditions are set in in the combo box. Here, I am trying to...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
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,...
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
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...

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.