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

Can't remember how to do this

489 256MB
have you ever tried doing something and just can't remember how to do it. Well that's what happened here.
I have 16 bonus labeled bonus1 through bonus16 in a table, the design of the database was done a long time ago and it's to large to change the design at this time.
So instead of setting up 16 separate commands I would like to use a subscript I to change each bonus.
Expand|Select|Wrap|Line Numbers
  1. me.Bonus1 = 0
to something like
Expand|Select|Wrap|Line Numbers
  1. me."bonus" + i = 0
this doesn't work and I've tried many different approaches and keep getting some sort of error.
Can someone show me the correct format to do this or is it not possible.

Thanks.
Sep 29 '18 #1

✓ answered by PhilOfWalton

OK, I gave the cut down version

I don't know where you are running the code, but you should have something like

Expand|Select|Wrap|Line Numbers
  1. Sub XXX
  2.     Dim i As Integer
  3.     For i = 1 to 16
  4.         Me.Controls("bonus" & Chr$(i)) = 0
  5.     Next i
  6. End Sub
I actually don't believe the word "Controls" is strictly necessary.

Phil

5 987
PhilOfWalton
1,430 Expert 1GB
Try

Expand|Select|Wrap|Line Numbers
  1. me."bonus" & Chr$(i) = 0
Phil
Sep 29 '18 #2
CD Tom
489 256MB
I tried that and get the following error> "Compiler error: Expected identifier or bracketed expression" if I put brackets around it I don't get an error until I run it
Expand|Select|Wrap|Line Numbers
  1. me.["bonus" & chr$(i) = 0]
then I get this error Can't find the field'|1' referred to in your expression.
I've tried every possible [ and keep getting errors.
Sep 29 '18 #3
PhilOfWalton
1,430 Expert 1GB
OK, I gave the cut down version

I don't know where you are running the code, but you should have something like

Expand|Select|Wrap|Line Numbers
  1. Sub XXX
  2.     Dim i As Integer
  3.     For i = 1 to 16
  4.         Me.Controls("bonus" & Chr$(i)) = 0
  5.     Next i
  6. End Sub
I actually don't believe the word "Controls" is strictly necessary.

Phil
Sep 29 '18 #4
CD Tom
489 256MB
Ok that will work. Thanks
Sep 29 '18 #5
twinnyfo
3,653 Expert Mod 2GB
Phil is also correct:

Expand|Select|Wrap|Line Numbers
  1. Me.("bonus" & Chr$(i)) = 0
will work perfectly fine.
Sep 30 '18 #6

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

Similar topics

4
by: Rob Meade | last post by:
Lo all, This is rather embarrassing.... I am having some difficulties with an html table... I have... 1 left nav bar which spans 2 rows to the right - these are used for horizontal...
4
by: Rich | last post by:
Hi all I am using DEVCPP 4.9.8.1 which uses MingW32 GCC 3.2 compiler I am trying to compile this program, but without success, I am sure the compiler is set up ok, as I can compile and run...
5
by: Varun | last post by:
Hi Folks I am starting to learn VB.NET. A problem that i have encountered is that i cannot seem to use the values in my textbox accross forms for example i have 2 forms. On form2 i have a...
3
by: Me | last post by:
Hi Folks I keep recieving the following error message when i try to bind a combobox to the value that is in a textbox. the application crashes on the following line... Me.CBoxTitle.SelectedItem...
0
by: CMEDIA_SOUND | last post by:
I have a peculiar problem, I have a tabpage with a label control on it. When i set a background image to the tabpage and drag the label around it has paint issues in that it is slow, granted the...
7
by: William.Zhang | last post by:
the following code: template <class T> class test{ typedef T::XXX x; }; int main(){ return 0; }
4
by: Adrian Parker | last post by:
In asp.net, is there any way of stopping the browser from outputting the message.. "Do you want Windows to remember this password, so that you don't have to type it again the next time you visit...
3
by: foxygen | last post by:
Hi, maybe i'm a new coder from this post or discussions etc. but i cant do this. can you help me ? its about polymorphism. Implement a shape hierarchy with Shape as an abstract base class that...
5
by: chevon1920 | last post by:
I am trying to do my assignment but I cant figure out how to get 8 data points per line to print to a file. Here is the assignment 1. Program asks the user to enter an odd number as a BASE,...
2
by: ratinox | last post by:
This is the code i was working on. i know it is clunky but im new to this. at the spot that sais RIGHT HERE i am getting this error statement when i try to run it: when casting from a number the...
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: 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
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?
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,...

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.