Arrays
Jun 25, 2007
Hi all
I need some help with an array.
I have 10 fields each with 5 possible values. At the moment I've written 50 if then statements.
is there a cleaner way to do this?? I thought perhaps an array of some sort may do the trick.
Any advice is appreciated
Damon
soc5 = DLookup("[effort]", "values_effort", "ID=5")
soc4 = DLookup("[effort]", "values_effort", "ID=4")
soc3 = DLookup("[effort]", "values_effort", "ID=3")
soc2 = DLookup("[effort]", "values_effort", "ID=2")
soc1 = DLookup("[effort]", "values_effort", "ID=1")
soc0 = DLookup("[effort]", "values_effort", "ID=0")
's1
If Me.txtFieldS1 = 5 Then Me.txtS1 = soc5
If Me.txtFieldS1 = 4 Then Me.txtS1 = soc4
If Me.txtFieldS1 = 3 Then Me.txtS1 = soc3
If Me.txtFieldS1 = 2 Then Me.txtS1 = soc2
If Me.txtFieldS1 = 1 Then Me.txtS1 = soc1
If Me.txtFieldS1 = 0 Then Me.txtS1 = soc0
's2
's3
's4
..
...
...
View Replies
Jun 23, 2005
I am not even totally sure that is what you call it. . but I have most of my experience in VB.NET and this VBA in Access 2002 is killin me. HA. . .
I am trying to dynamically create checkboxes (50 of them) in 10 rows and 5 columns. This is part of a "im bored" project and would like to be able to tackle the dynamic controls area.
I am thinking I want to keep the naming convention as "chkBox01. . .02. . .03" so that I can use the mid() function to determine its "value" and apply the value in the proper place.
I suppose the only thing I need is an example if anyone has one of a checkbox or any control for that matter being made by VBA and not placed on the form manually. 50 check boxes suck when trying to rename them all. sigh
View 11 Replies
View Related
Jan 24, 2008
Hi,
How can I determine the length (size) of a dynamic array so I can iterate over it?
Thanks,
Mike
View 2 Replies
View Related
Jun 1, 2006
Is there anyway to name text boxes in an array format?
i.e. Text(1,23)
Or if not is there anyway to use VB to cycle through the text boxes
i.e
i = 1
Loop until i = 25
Text(i) = codehere
i = i + 1
Exit Loop
Matt
View 3 Replies
View Related
Nov 11, 2013
What's the best way of storing arrays of data within a cell? Or should I be creating fields to the size of the array.The size of the arrays are unknown at the moment.
View 7 Replies
View Related
Dec 27, 2014
I have a form that allows me to sell animals in a group. While some fields, (i.e. buyersname, sellingunits, datesold) are good for all, some fields (i.e. AnimalID, SellingWgt, Sellingprice, Picture) need to be specific.
Having said this, Using a query for GroupSales, I filled a list box of all the animals that are to be sold. Below the list box two command buttons (1-ALL) and (2-by Group).The only difference being here, is that by clicking cmdALL all animalIDs listed in the list Box will be highlighted. The By-Group means the user has to highlight the IDs they want to sell..
In either event, there will multiple IDs. If I can use arrays here, I could include the other fields for each animal that has been chosen. These would then be updated/appended to other tbls.
View 4 Replies
View Related
Aug 28, 2012
Are there no arrays in Access? I am looking for a way to put sequential dates onto a calendar. An array would work fine, with an offset for Weekday(FirstDayOfMonth).
View 1 Replies
View Related
Mar 4, 2014
Question 1:
I am attempting to make a macro to pull information based on a clicked button to provide information to another form. While my example below will be rudimentary, I am attempting to create so that it can be applied to 450 buttons, hence the need for it to be a macro and not simply code per button.
For example if I have 3 buttons, captioned: red, green and blue. If I click on the blue button, it will open another form with a text-box that will say 'blue'. Likewise, if I click the red button the text-box will be changed to 'red'.
In the code below the section that I need to change is: Command1.Caption. Using this data I can pull from the one button to create the value, but I need it to be based on an OnClick or something in order to pull the value from the right button.
Example:
Function Macro1()
On Error GoTo Macro1_Err
DoCmd.OpenForm "Form2", acNormal, "", "", , acNormal
Forms!Form2!Text0.Text = Forms!Form1!Label0.Caption
DoCmd.GoToControl "[Text2]"
Forms!Form2!Text2.Text = Forms!Form1!Command1.Caption
[code]...
Question 2:
I am trying to use a query to change button colour on the basis of values stored in a table.What I want to do is change the button background after comparing the button name to the same variable in a table, and determining another variable.
IE:
Button1, Button2. In table: Button1, Val = Y, and Button 2, Val = Z
Pseudo Code:
Array: From Button1 to Button2
Query for Button1 against table
If Val = Y, Button1.background = red
Else if Val = Z, Button1.background = blue
Else Button1.background = black
End if
View 4 Replies
View Related