Dynamic Arrays
Jan 24, 2008Hi,
How can I determine the length (size) of a dynamic array so I can iterate over it?
Thanks,
Mike
Hi,
How can I determine the length (size) of a dynamic array so I can iterate over it?
Thanks,
Mike
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
..
...
...
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
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
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 RelatedI 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.
I have a form that shows a list of all of my records in my database. I want to be able to click a button called "Report" and have that print a report that has all the records I have filtered on my form. I have a report in the format that i want it in, however, currently it prints every record and not just what is shown on my form. (The form is dynamic and I want the Report to be dynamically based on the form) HELP PLEASE!
View 6 Replies View RelatedAre 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 RelatedQuestion 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
Hey,
I made a table Products: order number (key), name, supplier, price,...
I copied it into a query, and made a form of it, so I can look up products by order number with a combo-box. Now I'm into my next step (and it gives me a headache):
In the form I added a new text box, where I should put the incoming amount of a product in, and another text box to put in the products that are empty.
Now the question: how can I make a query that counts the amounts of incoming and empty products, as well as the difference between those two, in a way I can do multiple additions?
I hope you know what I mean by dynamic sum: start stock=0 first delivery: +3==> stock 3 +next delivery: +6 ==> stock 9,...
If anyone has some idea...
Thanx in advance
Kev
Hi guys, I am trying to create a form or subform that should be created after a button is pressed and some complex filetering is occured and records are saved in a multiple arrays so I need to generate a form and controls according to those array values. Please help.
Actually I can not get data directly out of the query its just too complex bla bla bla. Finally I have three arrays each array has same number of values and I want to generate a form on the basis of the values of the array. Please Help me. I have tried creating form but Could someone please show me the right path.
many thanks
Now, I don't know if this topic should be in forms, queries or reports, so I decided to post it here in general until someone gives me a big bollocking and send this topic elswhere :D
I have a table with loads (50+) of columns which hold information about people in our company.
What I want is a form? that allows me to tick the information I want and then displays the result in a report.
So, today I want a list with Name, address, town and phonenumber, but tomorrow I might need a list with Name, phonenumber, passport number and expire date.
In short, I need to make a 'dynamic'? report that displays the options I ticked out of the 50+ options (does this make sense?).
I searched for it but no luck so far.
Ta in advance
Hello,
I have two tables: Categories and Subcategories.
Categories contains one field: CategoryName
Subcategories contains two fields: ParentCategoryName and SubcategoryName.
In a third talbe I want to select a category from a listbox, then have the subcategory listbox update automatically with the possiblities. Is this possible?
Thanks.
Not sure that this fits under table but I believe that is the root of the solution, so we'll try it here.
I'm building a database to simplify the process of creating a PC build sheet for my company. I would like it to track pricing and everything as well so here is where the problem comes in:
Say right now a floppy drive costs our customer 10 dollars. In a few months, we could still be using the exact same floppy drive, but the price has dropped to 9 dollars. If I run a report to display all computers sold in the past year (including pricing), I want the floppy to have the price that the customer paid at the time; not the latest 9 dollar price only.
Correct me if I'm wrong, but here is my thinking:
I could run a macro to rename the $10 floppy drives and update it in all old records (though I have a feeling I'd have to pull a trick out to mess with UIDs) then update the price on it for the list of options when building out a computer, but it seems like I should be able to automate this better.
Possibly some sort of linkage table?
I'm just trying to keep this as clean as possible so I'm not digging back through this a year down the road.
i have a database that imports files with dynamic amounts of fields, runs querys on the data and outputs it to a speadsheet. The The problem is instead of making it run querys on each column, i have it running on them all collectively. Now i want to change it so a query is run on each column then output to its own spreadsheet. Does anyone know how to do this?
View 1 Replies View RelatedI have a form where a user chooses different criteria from listboxes and then I run out and format the SQL statement.
This is the query that I am trying to replicate using VBA code. Note: the Location_ID, Ship_Day, and Final_Dest come from the values in the listboxes.
I am getting a syntax error and I cannot find it anywhere. Also, is there an easier way to do this?
SELECT [(Table) Denton Routing].LOCATION_ID
, [(Table) Location].NAME
, [(Table) Location].CITY
, [(Table) Location].STATE
, [(Table) Location].REGION
, [(Table) Denton Routing].UNIQUE_LANE_ID
, [(Table) Denton Routing].CARRIER_ID
, [(Table) Denton Routing].[SHIP DAY]
, [(Table) Denton Routing].[DELIVERY DAY]
, [(Table) Denton Routing].[TIME AT LOCATION]
, [(Table) Denton Routing].STOP_NUM
, [(Table) Denton Routing].NO_OFF_STOPS
FROM [(Table) Location] INNER JOIN [(Table) Denton Routing] ON [(Table) Location].[LOCATION ID] = [(Table) Denton Routing].LOCATION_ID
WHERE ((([(Table) Denton Routing].UNIQUE_LANE_ID) In (SELECT UNIQUE_LANE_ID
FROM [(Table) Denton Routing]
Where [(Table) Denton Routing].Location_ID = "13176AA"))
AND (([(Table) Denton Routing].[SHIP DAY])="MONDAY"
AND [(Table) Denton Routing].Final_Dest = "DENTON"));
Here's the code:
Private Sub cmdRunQuery_Click()
Dim Db As DAO.Database
Dim QD As QueryDef
Dim where As Variant
Set Db = CurrentDb()
' Delete the existing dynamic query; trap the error if the query does
' not exist.
'On Error Resume Next
'Db.QueryDefs.Delete ("Dynamic_Query")
'On Error GoTo 0
where = Null
where = "WHERE ((([(Table) Denton Routing].UNIQUE_LANE_ID) In (SELECT UNIQUE_LANE_ID FROM [(Table) Denton Routing] where"
where = where & " [(Table) Denton Routing].[Location_ID]= '" + Me![Text35] + "'"
where = where & " AND [(Table) Denton Routing].[Final_Dest]= '" + Me![List29] + "'"
where = where & " AND [(Table) Denton Routing].[Ship Day]= '" + Me![Combo46] + "'))"
MsgBox (where)
Set QD = Db.CreateQueryDef("Dynamic_Query", _
"Select SELECT [(Table) Denton Routing].LOCATION_ID, [(Table) Location].NAME, [(Table) Location].CITY, [(Table) Location].STATE, " & _
" [(Table) Location].REGION, [(Table) Denton Routing].UNIQUE_LANE_ID, [(Table) Denton Routing].CARRIER_ID, [(Table) Denton Routing].[SHIP DAY], " & _
" [(Table) Denton Routing].[DELIVERY DAY], [(Table) Denton Routing].[TIME AT LOCATION], [(Table) Denton Routing].STOP_NUM, " & _
" [(Table) Denton Routing].NO_OFF_STOPS FROM [(Table) Location] INNER JOIN [(Table) Denton Routing] ON [(Table) Location].[LOCATION ID] = " & _
" [(Table) Denton Routing].LOCATION_ID " & (" where " + Mid(where, 6) & ";"))
DoCmd.OpenQuery "Dynamic_Query"
End Sub
Say I have 3 fields in my table: FstName, MidName, LstName.
I want to be able to dynamically change the sort order of a query to different sort orders using the same fields via a form.
I may want to see the records sorted by LstName, MidName, Fstname; and another time see the list sorted by Fstname, Lstname, MidName; and other times by any combinations possible using the 3 fields.
I see 3 options: filter by form; programatically change the SQL Order By clause; or concatenating the table fields together in the desired order via a custom function and sorting by the function result.
Is there any difference in query/form performance between the 3 options?
NEW PROBLEM! :)
Sorry for the double post.
Hi all, I'm currently strugging with an Access problem and wondered if anyone here could give me some ideas. This is fairly complicated to explain, so please bear with me!
Basically, I have a query that pulls out a list of users, and another query that pulls out of a list of possible applications that that may be assigned to them.
What I need to do is present this in a form, so that my app user can browse through the list of users, and assign/deassign applications to that user. I'm thinking of presenting this along the lines of a list of users down the left of the screen, a list of apps along the top of the screen, and a checkbox for each app/user combination.
The complication is the list of possible applications is different every time the form is loaded. There are 1500 possible apps, and ANY combination of these may be available.
My most recent attempt at this was to find the list of apps, and then (using vba) create a temporary table, with a "User id" field, and then a "yes/no" field for each app that is available to this group of users. I can then present this in a subform, allowing the tickboxes to be viewed and modified for each user/app combination.
However, my problem is that when I dynamically try to alter the recordSource of the subform, the field names are different each time, so it doesn't display the app names I need. I've searched Google etc, and the only relevant suggestion is to have multiple subforms, and display the one that suits. However, with such a huge number of possible combinations of apps, I cannot take this approach.
So, is there any way that I can easily update the subform to have the correct columns? Or am I going about this in entirely the wrong way?
Any suggestions will be gratefully received - I'm hitting a brick wall with this at the moment and don't have much hair left to pull out!
I have a main form that displays different part numbers and the corresponding material type for each item. For example,
Part 1 metal
part 2 candy
part 3 label
I have created specific subforms based on the type of the material. I want to place a command button on each record, and when the button is clicked, the correct subform based on the material code will open. For example, the above 3 items are displayed on the form, if the user clicks the button next to candy, then the candy subform opens and if the user clicks the button next to label, then the label subform opens.
Thanks for helping solve my question.
Jeff
hi,
i'm having a problem making my report dynamic, i have a query which returns the
payments due in the next month, my question is, if i have a form based on this query,
how can i make it so that, if i need to print an invoice for one of the customers, lets say the currently displayed record,
how can i limit the customers displayed in that report (invoice) to just the current record that i want the invoice for?
Thanks
I have several tables but lets focus on two Table1 and Table2
Table1.ID is a foriegn key in Table2.NewID
I want the default value for Table2.NewID to be the MAX of Table1.ID; that is I want Table2.NewID to auto default/select whatever is the highest ID of Table1.ID. I have toyed with this as much as I can by entering different SQL statements in the the default field of the datasheet. And by defining different Macros for OnFocus event.
I am looking to basically update the hyperlink base every time the database is opened to be the folder that the database is currently in.
We are trying to make the database and supporting information portable, so that people can copy the entire folder anywhere on their computer and all of the links will still work. I can't put all of the info in the database because we are already pushing the size limit.
I would like to keep it from getting terribly complicated, as others will have to update this database with more info in the future and make the links themselves.
If there is a better or different way of getting the same result without going through the hyperlink base, that is fine.
Any help would be appreciated.
Thanks.
Hello to all,
I created a dynamic report based on cross tab query, the header is a sub report.
Number of lines and rows depend on the data typed in a form.
Here is my problem. When numbers of rows exceeds for exemple 15 the header and detail line continue on the line below i would like the report continue on another page (see below).
Actualy i have this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
16 17 18 19 20
line1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxx
line2xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxx
etc..
I would like this:
page 1:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
line1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
line2xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
etc...
Page 2:
16 17 18 19 20
line1xxxxxxxxx
line2xxxxxxxxx
etc...
THANKS IN ADVANCE FOR HELP.
VINCENT
I have the following Tables in my database:
Categories | Sub Categories | Products
Categories has the following fields:
Floors | Exterior | Interior
Subcategories has the following fields:
Carpet | Vinyl | Wood | LapSiding | Shingles | Insulation
I have a form called Order Details and when entering the products through my form I have two "Lookup" fields, the first which is CatID which will return a dynamic listbox in the "Categories" field containing "Floors, Exterior, Interior" pulling from the Categories table.
The second is SubCatID which will return a dynamic listbox in the "Sub Categories" field containing "Carpet, Vinyl, Wood, LapSiding, Shingles, Insulation" pulling from the Sub Categories table.
I am however having problems with my third which is "ProdID". I am wanting it to also be created dynamically through a "Lookup" on the Products table. I want when I choose for instance, "Floors" and "Carpet" from the Order Details that only the choices that match those two ID's populate the "ProdID" field and only the products for carpet not for Shingles or other sub categories.
I hope this makes sense...
TIA for any help that you can offer.
Donm
As much as I would like to tell my boss he's insane I'd also like to keep my job. I know this is possible, but it sounds very complicated. Basically, I need a way to generate queries on the fly. This is geared towards someone who doesn't know SQL of course. I know basically what he's looking for, comparing sales over some period of time. However, he might want annual numbers, quarterly numbers, percentages, overages/shortages, and any kind of sales related query you can think of. The only way I figure I can do that is to have a form build the SQL statement, save the SQL statement as a query, then have him open the query. Is there another way I can do this without necessarily saving a query first?
View 6 Replies View Related