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

using a variable as part of the reference path

7
I'm trying to set up a value for a control on the report and part of the path should be a variable, since I have multiple objects like that. So when I try to put a variable I'm getting the "Compile Error: Syntax Error" message and don't know how to handle it.

Reports!rptFlgTest!"& strFieldName &" = -1

I've tried to put single quotes around double ones as well as not to use any; or not to use ampersands while having either single quotes or double ones or both and nothing worked! In the hardcoded version, however, i.e. when the actual name of the check box on the report is hardcoded in the path, like

Reports!rptFlgTest!CheckBox1 = -1

the code compiles and assigns a value to the control like it is expected.

Anybody knows what syntax I should use for a variable?
Aug 8 '07 #1
3 1388
Killer42
8,435 Expert 8TB
...
Reports!rptFlgTest!CheckBox1 = -1
...
Anybody knows what syntax I should use for a variable?
Generally speaking, the controls will be in the Controls collection, where you should be able to use a string to refer to them by name. So for example, I think (not positive) that in the above code you could have used Reports!rptFlgTest.Controls("CheckBox1") = -1
If that works, then of course it follows that you can use a variable in place of the string.
Aug 9 '07 #2
waltvw
7
Generally speaking, the controls will be in the Controls collection, where you should be able to use a string to refer to them by name. So for example, I think (not positive) that in the above code you could have used Reports!rptFlgTest.Controls("CheckBox1") = -1
If that works, then of course it follows that you can use a variable in place of the string.
Thanks for the response. Right after I posted my question I found an answer to it, which was putting my string variable in parenthesis:
Reports!rptFlgTest!(strFieldName) = -1

In fact, I went 1 step further and eliminated the variable, putting a path to a field returned by SQL statement in parenthesis:

Dim rsttblFlags As Recordset

strSQL = 'some SELECT St-t here that retrieves rows from a MS Access table'.
Set rsttblFlags = dbs.OpenRecordset(strSQL)
Reports!rptFlgTestSingleCusip!(rsttblFlags!FieldNa me) = -1

Thanks again for your help!
Aug 10 '07 #3
Killer42
8,435 Expert 8TB
Thanks for the response. Right after I posted my question I found an answer to it, which was putting my string variable in parenthesis:
Reports!rptFlgTest!(strFieldName) = -1
...
Glad to see you got it working.

As a matter of fact, that's pretty much the same thing I did, you simply allowed it to take the default collection (Controls) while I included it, because I didn't know for sure whether it was the default.
Aug 11 '07 #4

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

Similar topics

7
by: Michael J. Astrauskas | last post by:
I have a script, which I've called test-loadpic.php and some pages reference it by means of <img src="test-loadpic.php?sourcepic=$picNum"> where $picNum stores a number. This part itself works...
1
by: Erick Bodine | last post by:
I am trying to set a new environment variable on a W2k machine with only partial success. The name("SSID") and value("ASIM") show up correctly in the registry and when I go to "System...
28
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
3
by: Anders Borum | last post by:
Hello! I've come across a strange error that occurs, when you try to return a nodelist from a variable with a choose/where/otherwise statement. I'm not quite sure whether it's a bug or simply...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
3
by: Marco Shaw | last post by:
I've got some C# code to create a custom PowerShell cmdlet with these statements: .... using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; .... ...
65
by: Arjen | last post by:
Hi, Form a performance perspective, is it wise to use the ref statement as much as possible? Thanks! Arjen
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.