Problem with this database please help

naym

Registered User.
Local time
Today, 16:32
Joined
Aug 30, 2006
Messages
47
Hi All
I have been having problems with some code inside this programme for a while now and i have hit a blank wall, i have tried all sorts even posted on here with the porblem but no look so am having to try again with the database this time.

The problem is that i am trying to load the items from the table into a a command button, now with access you can create an array say cmd and have 10 buttons called cmd you have to name them cmd1 cmd2 cmd3 and so on to cmd10.

Now i have managed to load the department items from the department table so they all load up fine the problem i am having is if i click on say a department called chicken it should only load up the chicken section in the products cmd buttons but it actually loads up all the products in all sections not just chicken so it will load up all the product cmd butons with lamb products fish products etc thats the first problem and the second problem i am having is when a product is click say chicken wings the that products price and name should be displayed ina form.

I ahve attached the programme and would be very very greatfull if anyone can come up with an answer to this as i have been struggling on it a while now.

many thanks
 

Attachments

I don't quite understand what you're trying to do but I suspect you're heading down the wrong road. Must guess then is that maybe you should doing all this with cascading combo boxes. With what you are doing it lloks like you have 6 primary types of food items and for each one of those you want 6 sub-categories and for each sub-categories you finally have actual items. This model will not scale at all. Meaning that if you need to drop or add a food category or sub category you'll have to go back in a progam the database...

:)
ken
 
Hi m8 i just had a real quick look at your db and the Command Button Test (thats as much looking as I did) is well frankly terible.. i know this form is obviousyl in its early stages of development but what will make your life SOOO much easier is cascading comboboxes (dropdown list). This will not only be alot easier to code but from a HCI (Human Computer Interfaces - study of humans perception of a Computer GUI) perspective it makes alot more sense.. This method will mean you wont have to have subform upon subform as you have simply 1 or maybe 2 forms which keeps it nice and easy for the user.
Sorry to be an arse and im sure people will disgree with what i have sed!

Anyways lookup Cascading Comboxes this should put you on your way and if not come and shout back..

good luck
 
haha Ken piped me to the post i shouldnt have dordled around!! at least we're on the same page! I just sound like an absolute git and you sound like a nice guy.. ! oh well home time for me... :D
 
Thanks guys for the reply firstly the test command button doesnt work at the moment only the first 2 command buttons actuallu run and call the loadprod procedure and also i am a newbie to programming so bare with me please.

Secondly thanks ken for the reply and i know what you are saying about having them in combo box but the reason why i am doing this way is because this system will be used on a touch screen system and the 6 categories are not the actual categories i will prob have about 10 or 15 depending on the menu also i might have to buttons a next and previos so it will cycle thorugh to the first say 7 and when the next button is clicked the same category command buttons will be displaying the next set of command buttons.
i have done something similar in vb which works fine but just having a problem on this as vb the report designers etc are a bit difficult to work on and since access is a bound type database it would be best to do it in access,

hope that had cleared of what i am wanting to do. if someone has a better idea that can be used witha touch screen i would really like to hear from them i tried thinking of using toggle buttons but i think that command buttons will be the better option.

many thanks for the replys
 
Hum... Never had to consider a touch screen app... Maybe someone else will jump in and help...

:)
ken
 
Yep thats what is the big porblem, i know it cant be that hard i have seen it done in a similar way and also i have done this in visual basic but command buttons there are just all called say cmddepartment and they are all stored in an array.
Lets just see and hope someone knows how to solve this problem or knows of anyway about it, thanks anyway ken.
 
Here is an approach that you can CONSIDER - but remember that you are asking for a BIG headache because of its dynamic nature. If you are not good in VBA, don't try this at home. (If you do try it, you'll be a lot better at VBA when you are done, I assure you.)

1. Form is almost guaranteed that it must be unbound. You will be doing everything based on dynamic recordsets.

2. Define ahead of time the maximum number of buttons you will allow to be on screen at once. This will be essentially a visibility/touch-screen resolution issue.

3. Look up definitions of these terms in ACCESS HELP:

LEFT - as in, location of left edge of a control
TOP - as in, location of top edge of a control
WIDTH - as in, width of a control from left to right edge
HEIGHT - as in, height of a control from top to bottom edge
CAPTION - which is a property of command buttons that don't have pictures
TWIPS - which is the unit of measure on screens
VISIBLE - which is a property that lets you see something
ENABLED - which is a property that allows something to be actively used
RECORDSETS - learn how to manipulate, query, dynamically build the SQL to create an on-the-fly recordset AND QUERY IT.

4. Create a form with all of your command buttons that you will allow at one time. Name the buttons CMDBUT001 through CMDBUT0nn, nn= max allowed.

5. In the ONCLICK routine of each button, write code that stores a constant (equal to the button number) in a central variable declared in the form's class module's declaration area. Have a couple of arrays - probably strings - in that same declaration area, defined to have as many elements per array as the number of buttons you will allow. Have a "TOP" and "LEFT" variable (named something other than TOP and LEFT, which are keywords) in this area too. Finally, you will need some sort of STATE variable that shows you what is next on the agenda - INITIAL button, continuing selection DRILL-DOWN (which is probably a loop of some sort, but you could sub-divide it), OTHER action, whatever states you define.

6. After storing a value in the ONCLICK, have the same action routine call a common routine that does the following in VBA:

a. Identify which button was pushed from that common variable.
b. Decide on what you want to do to restructure everything.
b.1. If this requires you to open a dynamic recordset, build your SQL based on the current selection.
b.2. execute the dynamic SQL
b.3. When you are finished with this, remember the kindergarten rules: If you opened it, close it. If you take it out, put it away. If you mess it up, clean it up. OTHERWISE, you will eventually get an "OUT OF MEMORY" error of some flavor.
c. IF this action means you will be displaying a different set of buttons, then
c.1. reload the class-module arrays with the NEW title and any other new info you need for the next action. (Probably you will do this in the stuff I've labeled "b" earlier, but it is hard to get everything in the right order.)
c.2 In a loop AFTER c.1, rebuild the buttons based on the array contents. Reset the button-builder position data.
c.3 For each button starting from 1,
c.3.a. Move the button to the stored TOP and LEFT area.
c.3.b. Update the stored TOP and LEFT area
c.3.b.1 If you have room, just add WIDTH to the LEFT placeholder.
c.3.b.2 If not, reset the LEFT placeholder to the reference LEFT and add HEIGHT to the TOP placeholder instead.
c.4 After all "active" buttons are defined, as a separate loop, reset the rest of the buttons to move them to a neutral "resting place" that is NOT part of your active display area. Mark them .VISIBLE=false, .ENABLED=false. They can overlap in that place.
d. If this is not going to entail more buttons, then switch to (POP UP?) a new form. You might have to use a "MOVE_TO_FRONT action" -see the ACCESS HELP files on that topic, without the underscores perhaps...
e. When that new form comes back to you, reset your state variable to its INITIAL setting and reload your arrays appropriately.
f. The form's OnLoad event must simulate a button click that is, in essence, "RESET to TOP LEVEL"

This is as dynamic as it gets. The only saving grace MIGHT be if you have good indexes and a fast machine, you would be able to do this fairly fast. Otherwise, this could plod along like a couple of old mules with a heavy load.

WARNING: I consider this to be VERY VERY AMBITIOUS - but it sounds like it might do what you wanted done. The key to this will be the common "staging" routine that rebuilds the arrays and rebuilds the buttons.

Make several subroutines callable by the staging routine. I see at least one to build visible buttons, one to move invisible buttons, one to reload your button-defining arrays based on a dynamic query. Might be more than a few others here, too.

Remember that you can synthesize a name if you use an orderly method. E.g. "CMDBUT0" & Format$ of the index to build a string such as CMDBUT001, CMDBUT002, etc. So your loops can build the required name on the fly to pass in to your button relocator routines.

Arrays and variables you might need:

BtnCapt: Array of strings for the SHORT caption you want for each button
BtnCode: Array of ? to define what each button should do
BtnLeft, BtnTop: Scalars - Next place to put a button
BtnLeftMax, BtnTopMax: Scalars - constants you define some oddball way to limit the buttons you will build or otherwise give you a sanity check.
BtnUsed: Scalar for the button that was pressed to store its index.

Then you have
FrmState: A state code that tells the common routine the state it was in when it was called - and which is updated when anything does a state change.
LastSQL: A string to build the dynamic query implied by a DRILL-DOWN click event.

This is VERY rough and will not come into existence quickly. Nor should you consider this list definitive or complete in any way.
 
Last edited:
Thanks doc man for the reply

WOw ou ahve gone into pretty much quite a bit of detail there, havent been able to check it out properly yet as am still at work, but you are talking abour creating everything dyamnic even loading the buttons up and moving them, i dont want to do that all the buttons do is change to what ever the the department cmd buttons are for example if the fish cmd button is clicked then the products cmd buttons are filtered and nly the fish products are displayed, the way i ahve done it in vb is on the click even there is sql query which filters it out but the problem i am having is that access doesnt work with arrays like vb does so that query doesnt work.
Also why wud i want to move the command buttons why not when a differnt department is clicke the same product buttons change the caption to the department section to say lamb or example.


this is a query which i ahve tried which is the same as in vb but doesnt work
sSQL = "select ProdName From Products where departmentName = '" & cmd(i).Caption & "'"

it doesnt recoognise cmd(i) i can send the vb one if someone wants to have alook at it.

thanks again doc man

and hope it makes some sense

many thanks
 
Hi naym,

If I could make a sugestion,

Why dont you use cascading subforms in a similar way you would use cascading combo box's.

Set the subforms up as continuous forms.
Start with the a subform, Department as the record source.

Your second subform (also continuous form)
Query "Products" as the record source department, criteria like the department subform

And so on.

I would like to put together an example if you are interested.

Garry
 
naym, the alternative is that you must have one form for each member of a "selection" tree. You can do that, too. But you will be opening a sh*t-pot load of forms to get to the bottom of that list.

It is your call, and woe be unto you if you have to change the tree structure. But, yeah, you could do it.
 
This only a rough example of what I have interpreted you are looking for.

Let me know.

Garry
 

Attachments

Hi all
Thanks Guys for your views and thanks ZigZig for the working example what you have shown that could possibly work for but as am a newbie dont really know what you ahve done on the subforms so was wandering how would i get that into the 3rd subform, also with this idea there could be quite a few products added too.
Thanks also to you docman your views on my problem have been appreciated, but i didnt understand what you meant by a tree view, at the moment i do have something working but theyre on a tab control and all the butons are individually coded the pesuda code goes something like this

the subform product textbox = command me.caption
the subform price textbox = 2.5

so each button is individually coded so i need to create a way where i can update, or delete a product from a form.

ZigZIg if am not asking to much could you possibly have an example where when the product is clicked it is sent to the subform

many thanks guys
 
Hi Naym,

Here is what you asked for.
There are many ways to add data to the subform, this is just one example.

Garry
 

Attachments

youre looking for baisically a shopping basket functionality but made for a touch screen?
 
Maybe something like the following attachment.

There are a fixed number of buttons. In this example the user has already selected options two levels deep. Everything else should be self explainatory...
 

Attachments

  • screen_01.jpg
    screen_01.jpg
    19.3 KB · Views: 133
Hi All
Thanks ZigZag at first i didnt have this in mind but it shore can do the thing i was wanting to do i think it might eb a bit limited to take it further but its what i was looking for so thanks a million and thanks for the example your the man most deffintaly thanks guys
 
Sorry Ken didnt see your post there, yes thats looks pretty neat and kool would it be too much trouble if i could have an example programme of that possibly??
many thanks again guys
 
It was just a screen mock up. No code. Sorry :)

ken
 

Users who are viewing this thread

Back
Top Bottom