Combo's

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

I have created a lot of combo's based on my tables. Is this the correct way
to do it, or should I base them on a query that is based on a table.

All the combo's are set to be invisible except for the first one. Depending
on what is chosen, I wish to make others appear. Is it just a case of
setting the visible flag to true when this item is chosen from the
afterupdate of the combos'

To have all the combo's invisible at the start of a new record, I use the
OnCurrent event, and set all the visible flags to false, but when I return
to a previous record, this makes my previously used combo's invisible as
well. How do I keep all the combo's used visible, but those that are not
used need to remain invisible.

hope you can help (and understand what I'm on about)

Peter
 
Peter said:
I have created a lot of combo's based on my tables. Is this the correct way
to do it, or should I base them on a query that is based on a table.

All the combo's are set to be invisible except for the first one. Depending
on what is chosen, I wish to make others appear. Is it just a case of
setting the visible flag to true when this item is chosen from the
afterupdate of the combos'

To have all the combo's invisible at the start of a new record, I use the
OnCurrent event, and set all the visible flags to false, but when I return
to a previous record, this makes my previously used combo's invisible as
well. How do I keep all the combo's used visible, but those that are not
used need to remain invisible.

hope you can help (and understand what I'm on about)

Peter
 
Thanks, that starts me off with one combo visible if I create a new record,
all the others are hidden Great.. If I create a new record, select from my
hidden combo's a number of choices which will make more combo's visible, how
do I keep only those combo's visible that I have selected data from that are
relevant to that record. These may be different for each record when I
scroll through the records.

I hope you can understand what I'm tring to say.

thanks

Peter
 
Peter,

You need a procedure like this, which you'd call from the form's Current
event:

Private Sub SetComboStatus()
Me.Combo1.Visible = (x = y)
Me.Combo2.Visible = (Me.Combo1 = 123)
Me.Combo3.Visible = (Me.Combo2.Visible = True And Me.Combo2 = "xyz")
' and so on...
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Hi Graham,

Can you elaborate a bit further, I'm just trying to teach myself VBA.

in your first line, what does the =(x=y) mean?

the first combo I have is called "LossType"

If I choose option 2 or 3 from this, I set the Visible flag to True on the
"ProcessStep" Combo

This in turn can then open 1 of 12 Combo's

Do you think there is an easier way to do this, all I want to do is have all
the options available from Combo's so no one has to type anything.

Peter
 
An Example1st Combo is named "LossType"

from here I can make 7 selections

If I choose option 2 "BreakDown" this in turn makes the following visible

Combo2 "ProcessStep" from here I choose "Paper"
Combo3 "Paper" (there are another 11 combo's stacked under here)

Combo4 "BreakDownCause" say I choose "Electrical"
Combo5 "Electrical" ( 4 combo's stacked here, Electrical, Mechanical,
Pneumatic & Hydraulic)

Combo6 "ProcessLoss"

Combo7 "Action"

When I move off this record and return, I would like to see the above
combo's only. Can you adapt your code to do this , then I can follow on from
that. Perhaps, you can think of an easier way of doing this.

Peter
 
Graham,

I want to start again with my Database from scratch. Would you be willing to
help me set up the various tables/queries relationships etc..I need.

Previously I have lumped everything into 1 table, and when trying to create
various reports its not working as I thought it would.

Peter
A very grateful Brit
 
Peter,

Sorry for not getting back to you sooner, but I've been ill.

<<in your first line, what does the =(x=y) mean?>>
When you "wrap" and expression in brackets, it is evaluated as a logical
expression, meaning, "is this expression true or false?" So where we have
(x=y), we are asking "does x equal y? If so, the answer is a Boolean True,
and if not, a False. Therefore, we applied to the combo's Visible property,
we're saying make the combo visible if the expression is True, otherwise
make it invisible.

Since you've decided to start from scratch, just post whatever questions you
need to ask. If it's not me who helps, it will be someone else. That's what
this newsgroup is for.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Thanks Graham, I hope you are feeling better now.

What I am trying to do is create a Database of Machine downtime.

Depending on the type of stoppage, we have 10 steps to go through.

Step1 Basics
Date
Stop Time
Start Time
Crew
Product (combo if poss showing all products)

Choosing one of the option below requires one of the following steps. This
is the main reason for a stop. E.g If Choose Breakdown, I would like to
choose from prefilled combo's the steps required. Bot only make those
combo's appear that are required. The when I revisit the record, only those
used must show.

Step 2 LossType
Planned Maintenance (req. steps 1,2,3,4,10)
Breakdown (req. steps 1,2,3,4,5,6,9,10)
Process Loss (req. steps 1,2,3,4,5,7,9,10)
Start Up (Req. steps 1,2,3,4,10)
Other Downtime (req. steps 1,2,3,4,8,10)
Changeover (req. steps 1,2,3,4,10)
Machine Rework (req. steps 1,2,3,4,10)

Step 3 Scrap
Paper Scrap
Wet Scrap
Dry Scrap

Step 4 Energy
Burners Low fire
Burners Off
Fans Off

Step 5 Process Step
Paper: Reelstand 1, Reelstand 2 etc.. etc..
Dry Additives: Primary System, Stucco to Mixer etc.. etc..
etc... etc..

Step 6 Breakdown Cause
Electrical: PLC, Overload,Fuse etc.. etc..
Mechanical
etc.. etc..

Step 7 Process Loss
Paper Break (Lump)
Paper Break (Otehr)
etc... etc...

Step 8 Other Downtime
Paper
Stucco
etc.. etc..

Step 9 Action
Repair in situ
Repalce
etc.. etc..

Step 10 Comments
(a text box for comments)

What I have at the moment is everything lumped into 1 table. I have a main
form with loads of combo's giving the required choices. Some of these are
stacked on top of each other, becoming visibe when a related option is
chosen from one of the others.

The reason I chose Combo's was to make sure all the people using the
Database was to stop random entries plus it means less typing.

I did get this working, but struggled to make the correct combo's appear,
then when I returned to a previous record I couldn't make it remember what I
had chosen.

Plus by having it all in one table, my reports were no good, as they just
returned numbers instead of meaningful text entries.

I hope you get my drift.

Thanks

Peter
 
Thanks, but that is a bit ahead of my skills yet.

Can you give me any tips on on table design or what I require to start with
after the info I gave you.

thanks

Peter
 
Peter,

Either way, it's going to be complicated!

I'm afraid I don't have sufficient time to write this for you, so I'll give
you the gist of it, and hope you get the idea. You can always post more
questions to this thread.

We could store all this is a series of tables, but if it was me, I'd hard
code it.

1. Create the following procedure in the form's Load event:
Private Sub Form_Load()
Dim sStep2 As String
Dim sStep3 As String, sStep4 As String
Dim sStep5 As String, Dim sStep6 As String
Dim sStep7 As String, Dim sStep8 As String
Dim sStep9 As String, Dim sStep10 As String

'The following decimal numbers denote the required Steps.
'1 2 3 4 5 6 7 8 9 10
'The following binary equivalents are a code that represent
'each of the above numbers
'1 2 4 8 16 32 64 128 256 512

'The binary representation of the combinations of required
'steps are added to get a single number, as shown in sStep2.
'For example, if Steps 1, 2 & 3 are required, the code is calculated
as follows:
' 1=1 + 2=4 + 3=8
' =1+4+8
' =13
sStep2 = "LossType,Planned Maintenance,527,Breakdown, 831," & _
"Process Loss,863,Start Up,527,Other Downtime,655,"
& _
"Changeover,527,Machine Rework,527"
sStep3 = "Scrap,Paper Scrap,Wet Scrap,Dry Scrap"
sStep4 = "Energy,Burners Low fire,Burners Off,Fans Off"
sStep5 = "Process Step,Paper: Reelstand 1, Reelstand 2 etc..
etc..,Dry Additives: Primary System, Stucco to Mixer etc.. etc.."
sStep6 = "Breakdown Cause,Electrical: PLC, Overload,Fuse etc..
etc..,Mechanical"
sStep7 = "Process Loss,Paper Break (Lump),Paper Break (Otehr)"
sStep8 = "Other Downtime,Paper,Stucco"
sStep9 = "Action,Repair in situ,Repalce"
sStep10 = "Comments"
End Sub

You can see that the above procedure creates a bunch of string variables,
and stores all the information relating to the steps, and the combo values.

2. Unload sStep2 into a 2-column combo dataset, and set column 1's width = 0
(making it invisible). Any time you want, you can still get at column 1 by
issuing the following code:
iStepsRequired = CInt(Me.cboStep2Combo.Column(1))

3. Populate the remaining combo's in the same way.

4. When you need to decode the numbers (and thus deciding whether to make a
combo visible or invisible), do it like this:
To find out if a particular number is present in a code, logically AND
the sought number with the code. For example, if we want to find out if the
number 8 exists as part of code 831, this is what we do:
Me.cboMyCombo4.Visible = (8 AND iStepsRequired)

If 8 is indeed part of the code, the comparison will return a logical
True, otherwise it'll return False.

5. Since Step 10 is a textbox, of course there's nothing to populate, so
just make it visible or invisible, as the case may demand.

I know this seems complicated, and it is, but off the top of my head, this
seems to be the best way to do it. Perhaps others will be able to come up
with a better way.

Don't forget, if you don't understand something, or need help with any part
of it, don't hesitate to post more questions to *this thread*.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Back
Top