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

CurrentDB openRecordset search failed....

I am trying to copy a record with child records. The process is to copy
the parent and then search the child tables for record related to the
parent. When I try to search the child table for all related records I
get the following error:
Syntax error (missing operator) in query expression
'Configuration Id=28"'

I have shown the code below, any help would be appreciated.

---------------------------------------------------------------------------------------------------------------
On Error GoTo Err_cmd_Modify_Click

' Get the configuration id that is being copied
Me![sourceCI] = Me![Configuration Id]

' Copy the Configuration Item record
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste
Append

' Move to the last record in the table
DoCmd.GoToRecord , , acLast

' Update the revision number
Me![RevisionNumber] = Me![RevisionNumber] + 1

' Get the new configuration id
newCI = Me![Configuration Id]

' create a recordset with the DHS information for this CI
searchSQL = "Select * from Tbl_DHSDetails where Configuration Id =
" & newCI & """"

Set fromrec = CurrentDb.OpenRecordset(searchSQL)
fromrec.MoveFirst

Exit_cmd_Modify_Click:
Exit Sub

Err_cmd_Modify_Click:
MsgBox Err.Description
Resume Exit_cmd_Modify_Click

Aug 17 '06 #1
6 5252
Baz

"SpankyTClown" <ch**************@gmail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
I am trying to copy a record with child records. The process is to copy
the parent and then search the child tables for record related to the
parent. When I try to search the child table for all related records I
get the following error:
Syntax error (missing operator) in query expression
'Configuration Id=28"'

I have shown the code below, any help would be appreciated.

--------------------------------------------------------------------------
-------------------------------------
On Error GoTo Err_cmd_Modify_Click

' Get the configuration id that is being copied
Me![sourceCI] = Me![Configuration Id]

' Copy the Configuration Item record
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste
Append

' Move to the last record in the table
DoCmd.GoToRecord , , acLast

' Update the revision number
Me![RevisionNumber] = Me![RevisionNumber] + 1

' Get the new configuration id
newCI = Me![Configuration Id]

' create a recordset with the DHS information for this CI
searchSQL = "Select * from Tbl_DHSDetails where Configuration Id =
" & newCI & """"

Set fromrec = CurrentDb.OpenRecordset(searchSQL)
fromrec.MoveFirst

Exit_cmd_Modify_Click:
Exit Sub

Err_cmd_Modify_Click:
MsgBox Err.Description
Resume Exit_cmd_Modify_Click
There's a space in Configuration Id, put square brackets around it in the
SQL statement
Aug 17 '06 #2
Changed the sql statement to use
searchSQL = "Select * from Tbl_DHSDetails where [Configuration Id] = "
& newCI & """"

I get the same error.
Baz wrote:
"SpankyTClown" <ch**************@gmail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
I am trying to copy a record with child records. The process is to copy
the parent and then search the child tables for record related to the
parent. When I try to search the child table for all related records I
get the following error:
Syntax error (missing operator) in query expression
'Configuration Id=28"'

I have shown the code below, any help would be appreciated.

--------------------------------------------------------------------------
-------------------------------------
On Error GoTo Err_cmd_Modify_Click

' Get the configuration id that is being copied
Me![sourceCI] = Me![Configuration Id]

' Copy the Configuration Item record
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste
Append

' Move to the last record in the table
DoCmd.GoToRecord , , acLast

' Update the revision number
Me![RevisionNumber] = Me![RevisionNumber] + 1

' Get the new configuration id
newCI = Me![Configuration Id]

' create a recordset with the DHS information for this CI
searchSQL = "Select * from Tbl_DHSDetails where Configuration Id =
" & newCI & """"

Set fromrec = CurrentDb.OpenRecordset(searchSQL)
fromrec.MoveFirst

Exit_cmd_Modify_Click:
Exit Sub

Err_cmd_Modify_Click:
MsgBox Err.Description
Resume Exit_cmd_Modify_Click

There's a space in Configuration Id, put square brackets around it in the
SQL statement
Aug 17 '06 #3
If I hard code the SQL statement it works
Set fromrec = CurrentDb.OpenRecordset("Select * from Tbl_DHSDetails
where [Configuration Id] = 17;")

So its something to do with the quotes used in the statement.
SpankyTClown wrote:
Changed the sql statement to use
searchSQL = "Select * from Tbl_DHSDetails where [Configuration Id] = "
& newCI & """"

I get the same error.
Baz wrote:
"SpankyTClown" <ch**************@gmail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
I am trying to copy a record with child records. The process is to copy
the parent and then search the child tables for record related to the
parent. When I try to search the child table for all related records I
get the following error:
Syntax error (missing operator) in query expression
'Configuration Id=28"'
>
I have shown the code below, any help would be appreciated.
>
--------------------------------------------------------------------------
-------------------------------------
On Error GoTo Err_cmd_Modify_Click
>
' Get the configuration id that is being copied
Me![sourceCI] = Me![Configuration Id]
>
' Copy the Configuration Item record
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste
Append
>
' Move to the last record in the table
DoCmd.GoToRecord , , acLast
>
' Update the revision number
Me![RevisionNumber] = Me![RevisionNumber] + 1
>
' Get the new configuration id
newCI = Me![Configuration Id]
>
' create a recordset with the DHS information for this CI
searchSQL = "Select * from Tbl_DHSDetails where Configuration Id =
" & newCI & """"
>
Set fromrec = CurrentDb.OpenRecordset(searchSQL)
fromrec.MoveFirst
>
Exit_cmd_Modify_Click:
Exit Sub
>
Err_cmd_Modify_Click:
MsgBox Err.Description
Resume Exit_cmd_Modify_Click
>
There's a space in Configuration Id, put square brackets around it in the
SQL statement
Aug 17 '06 #4
Baz

"SpankyTClown" <ch**************@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
If I hard code the SQL statement it works
Set fromrec = CurrentDb.OpenRecordset("Select * from Tbl_DHSDetails
where [Configuration Id] = 17;")

So its something to do with the quotes used in the statement.

Correct, you've got too many of them! This should do the trick:

searchSQL = "Select * from Tbl_DHSDetails where [Configuration Id] = " &
newCI


Aug 17 '06 #5
There are no quotes in the example that works, so [Configuration Id] must be
a Number type (not a Text field.)

Therefore:
searchSQL = "Select * from Tbl_DHSDetails where [Configuration Id] = "
newCI & ";"
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"SpankyTClown" <ch**************@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
If I hard code the SQL statement it works
Set fromrec = CurrentDb.OpenRecordset("Select * from Tbl_DHSDetails
where [Configuration Id] = 17;")

So its something to do with the quotes used in the statement.
SpankyTClown wrote:
>Changed the sql statement to use
searchSQL = "Select * from Tbl_DHSDetails where [Configuration Id] = "
& newCI & """"

I get the same error.
Baz wrote:
"SpankyTClown" <ch**************@gmail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
I am trying to copy a record with child records. The process is to
copy
the parent and then search the child tables for record related to the
parent. When I try to search the child table for all related records
I
get the following error:
Syntax error (missing operator) in query expression
'Configuration Id=28"'

I have shown the code below, any help would be appreciated.

--------------------------------------------------------------------------
-------------------------------------
On Error GoTo Err_cmd_Modify_Click

' Get the configuration id that is being copied
Me![sourceCI] = Me![Configuration Id]

' Copy the Configuration Item record
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste
Append

' Move to the last record in the table
DoCmd.GoToRecord , , acLast

' Update the revision number
Me![RevisionNumber] = Me![RevisionNumber] + 1

' Get the new configuration id
newCI = Me![Configuration Id]

' create a recordset with the DHS information for this CI
searchSQL = "Select * from Tbl_DHSDetails where Configuration Id
=
" & newCI & """"

Set fromrec = CurrentDb.OpenRecordset(searchSQL)
fromrec.MoveFirst

Exit_cmd_Modify_Click:
Exit Sub

Err_cmd_Modify_Click:
MsgBox Err.Description
Resume Exit_cmd_Modify_Click
There's a space in Configuration Id, put square brackets around it in
the
SQL statement

Aug 17 '06 #6
Removing the extra quotes did the trick.

Thanks for all the help.
Allen Browne wrote:
There are no quotes in the example that works, so [Configuration Id] must be
a Number type (not a Text field.)

Therefore:
searchSQL = "Select * from Tbl_DHSDetails where [Configuration Id] = "
newCI & ";"
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"SpankyTClown" <ch**************@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
If I hard code the SQL statement it works
Set fromrec = CurrentDb.OpenRecordset("Select * from Tbl_DHSDetails
where [Configuration Id] = 17;")

So its something to do with the quotes used in the statement.
SpankyTClown wrote:
Changed the sql statement to use
searchSQL = "Select * from Tbl_DHSDetails where [Configuration Id] = "
& newCI & """"

I get the same error.
Baz wrote:
"SpankyTClown" <ch**************@gmail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
I am trying to copy a record with child records. The process is to
copy
the parent and then search the child tables for record related to the
parent. When I try to search the child table for all related records
I
get the following error:
Syntax error (missing operator) in query expression
'Configuration Id=28"'
>
I have shown the code below, any help would be appreciated.
>
--------------------------------------------------------------------------
-------------------------------------
On Error GoTo Err_cmd_Modify_Click
>
' Get the configuration id that is being copied
Me![sourceCI] = Me![Configuration Id]
>
' Copy the Configuration Item record
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste
Append
>
' Move to the last record in the table
DoCmd.GoToRecord , , acLast
>
' Update the revision number
Me![RevisionNumber] = Me![RevisionNumber] + 1
>
' Get the new configuration id
newCI = Me![Configuration Id]
>
' create a recordset with the DHS information for this CI
searchSQL = "Select * from Tbl_DHSDetails where Configuration Id
=
" & newCI & """"
>
Set fromrec = CurrentDb.OpenRecordset(searchSQL)
fromrec.MoveFirst
>
Exit_cmd_Modify_Click:
Exit Sub
>
Err_cmd_Modify_Click:
MsgBox Err.Description
Resume Exit_cmd_Modify_Click
>

There's a space in Configuration Id, put square brackets around it in
the
SQL statement
Aug 17 '06 #7

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

Similar topics

4
by: Matt Parkins | last post by:
I think I may have lost the plot. Just a few years ago I'm sure I wrote something similar to the following code: dim rst as recordset set rst = currentdb.openrecordset("mytable") ' blah blah...
2
by: TH | last post by:
I am (still :) working on a recipe database. Now I am trying to figure out how to set it up for an ingredient search. What I want it to be able to do is to search by one ingredient, sometimes by...
2
by: WindAndWaves | last post by:
I recently made a very simple little function: Function x() Dim Tbl As TableDef Dim fld As DAO.Field Set Tbl = currentdb.TableDefs("search") Debug.Print Tbl.Name For Each fld In Tbl.Fields...
11
by: MLH | last post by:
If this is what MySQL is set to... SELECT DISTINCTROW qryVehiclesNowners5.SerialNum, qryVehiclesNowners5.VDescr, qryVehiclesNowners5.Owner, qryVehiclesNowners5.VehicleJobID ,...
1
by: jnikle | last post by:
I have a parameter query named "qry_employee_info_reports" that I need to run in the OnOpen event of a form. I'm after its total number of records. The query's got several joins in it, and one of...
4
by: ray | last post by:
I am creating a new module in an existing ADP (new ground for me, have only ever used mdb's before). The module is a copy of some Albert Kallal code posted a while ago, which searches modules. ...
0
by: Alan Carpenter | last post by:
I'm curious about getting to the text of procedures in a database other than the current database without a new instance of Access. Note I don't want to execute or call anything, I just want to...
0
by: Steve Kershaw | last post by:
Whenever I do a search in Visual Studio 2005 the Local Help comes up just fine but the MSDN Online, Codezone Community and Questions areas give me an error that states: Search failed The...
6
by: Kirstin | last post by:
Hi, Can anyone help me with this error? I have this code: Set rs = db.OpenRecordset("Search") where search is a parameterised query. When I try to run it I get this error: "Two few...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...

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.