473,780 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with recordset name using string

I am having difficulty with an attempt at setting a recordset based on
a string.

The code -- Set rsSource = CurrentDb.OpenR ecordset("'" &
strSourceTable & "'", dbOpenTable) -- results in the following error:

"The microsoft could not find the object "vCUSTMR". Make sure the
object exists and you spell its name and path name correctly."

The tables do exist and are spelled correctly, the recordset "rs" is
obviously working fine as it is extracting the correct data "CUSTMR"
from tblTolasFiles. I've tried adding "Tables!" to the string with no
success.

Any help will be much appreciated.
Dim strSourceTable As String
Dim strDestTable As String

UpdateFileCount = 0
TolasFileCount = 0
Dim rs As Recordset
Dim rsSource As Recordset
Dim rsDest As Recordset

Set rs = CurrentDb.OpenR ecordset("tblTo lasFiles", dbOpenTable)

strSourceTable = "v" & rs!TolasFilenam e.Value
strDestTable = "tbl" & rs!TolasFilenam e.Value

Set rsSource = CurrentDb.OpenR ecordset("'" & strSourceTable & "'",
dbOpenTable)
Set rsDest = CurrentDb.OpenR ecordset("'" & strDestTable & "'",
dbOpenTable)
Nov 13 '05 #1
3 3972

Drop the quotes.

Set rsSource = CurrentDb.OpenR ecordset(strSou rceTable , dbOpenTable) --
results in the following error:

If ther eis the cghance that the table name contins spaces then

Set rsSource = CurrentDb.OpenR ecordset("[" & strSourceTable & "]" ,
dbOpenTable) -- results in the following error:

--
Terry Kreft
MVP Microsoft Access
"Nathan Bloomfield" <na************ **@hotmail.com> wrote in message
news:4b******** *************** ***@posting.goo gle.com...
I am having difficulty with an attempt at setting a recordset based on
a string.

The code -- Set rsSource = CurrentDb.OpenR ecordset("'" &
strSourceTable & "'", dbOpenTable) -- results in the following error:

"The microsoft could not find the object "vCUSTMR". Make sure the
object exists and you spell its name and path name correctly."

The tables do exist and are spelled correctly, the recordset "rs" is
obviously working fine as it is extracting the correct data "CUSTMR"
from tblTolasFiles. I've tried adding "Tables!" to the string with no
success.

Any help will be much appreciated.
Dim strSourceTable As String
Dim strDestTable As String

UpdateFileCount = 0
TolasFileCount = 0
Dim rs As Recordset
Dim rsSource As Recordset
Dim rsDest As Recordset

Set rs = CurrentDb.OpenR ecordset("tblTo lasFiles", dbOpenTable)

strSourceTable = "v" & rs!TolasFilenam e.Value
strDestTable = "tbl" & rs!TolasFilenam e.Value

Set rsSource = CurrentDb.OpenR ecordset("'" & strSourceTable & "'",
dbOpenTable)
Set rsDest = CurrentDb.OpenR ecordset("'" & strDestTable & "'",
dbOpenTable)

Nov 13 '05 #2
Thanks Terry,

I tried this but results in error Runtime 3219 "Invalid Operation".
Any ideas?

Nov 13 '05 #3
Well I've just tried the following

Dim rsSource As DAO.Recordset
Dim strSourceTable As String

strSourceTable = "Table1"
Set rsSource = CurrentDb.OpenR ecordset(strSou rceTable, dbOpenTable)

and it works fine.

BTW, ignore the advice I gave about the square braces it's not needed fo
this operation, so ...

Dim rsSource As DAO.Recordset
Dim strSourceTable As String

strSourceTable = "Table1 Space In Name"
Set rsSource = CurrentDb.OpenR ecordset(strSou rceTable, dbOpenTable)

.... works just as well.
--
Terry Kreft
MVP Microsoft Access
<na************ **@hotmail.com> wrote in message
news:11******** **************@ c13g2000cwb.goo glegroups.com.. .
Thanks Terry,

I tried this but results in error Runtime 3219 "Invalid Operation".
Any ideas?

Nov 13 '05 #4

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

Similar topics

10
1931
by: Angelo Secchi | last post by:
Hi, I have string of numbers and words like ',,,,,,23,,,asd,,,,,"name,surname",,,,,,,\n' and I would like to split (I'm using string.split()) it using comma as separator but I do not want to split in two also the "name,surname" field. In other word I would like python in separating fields to skip that particular comma.
1
3748
by: Gil | last post by:
This is a question involving CORBA but the problem shows up using Sun C++. The problem doesn't occur with Visual C++ 6. I'm using a string in the following form in my CORBA IDL declaration so both the client and server will have common strings defined. module A { interface B { const string MY_STRING = "thestring"; }
11
15588
by: KaHuNa | last post by:
I want create a string from a row of my db, but for each rows i need a new string and a new name for the variable. exemple: int i = myRow; string varName = "news"; createNameVar = varName + i; but i can't eval this in C#, also the strings news1, new2,...,newsN don't
2
1565
by: Mike | last post by:
Hello I load a text file into a string. Then I start seraching for a substring that appears many time in the file. Once I find an occurrence of the substirng I have to find the first accurance of " before it (there has to be one). Then I copy the substring starting with the first " until the index of the substring's occurrence I find the occurrence of the substring without any problems, and in most cases, I find the first " without any...
0
928
by: Fareast Adam | last post by:
Firstly, i have to capture name from textfield that have been submit then insert into db. Before inserting into db, i have to convert all the text into my own standard text, like below: 1. first letter must be big caps 3. both letter seperate with single spacing 2. support all unique char like " ' ", " @ " ex1: Mc'Downy@Michele Graham ex2: Ali bin Mahmood How can i do that? Any idea?
9
20439
by: redivider | last post by:
I followed discussion "access form control propertys via control name as string " but am getting NullReferenceException when trying to access any controls via their name using "this.Controls". private void mtbPh0_Leave(object sender, EventArgs e) { string callingControl = (sender as MaskedTextBox).Name; this.Controls.Visible=false; I've manipulated callingControl to increment the last character, and I've...
1
1184
by: zcabeli | last post by:
Hi, i want to refer to variable using a string that represent its name. i.e. in this example (which doesn't work ) i'd like to place value of 6 in 'y': $x = "$y"; $y = 5 ; eval($x) = 6;
6
2414
by: Andrus | last post by:
I need to create method which returns my application object type as string : TypeName(typeof( List<int>)) should return "List<int>" or "System.Collections.Generic.List<int>" TypeName(typeof( MyType<Customer>)) should return "MyNamesp.MyType<MyBusiness.Customer>" etc.
4
1426
by: Dev | last post by:
Can replacing this with stringbuilder advisable. Or since iteration is less only 20 times, the time taken by using strings and string builder will be the same. for( int i = 0; i< 20; i++ ) { strCell2 = "<input type=hidden id='Id" + rwCnt + "' name='id" + rwCnt + "' value='" + ID + "' />" + "<input type=hidden id='hidId" + rwCnt + "' name='hidId" + rwCnt + "' value='" + kEntityName + "' />" + "<input type=hidden id='setupType" + ID + "'...
0
9474
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10075
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8961
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6727
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.