Novice Coding Questions

C

cmirra

First of all, thanks for reading this. I'd apriticate any help I can
get in the matter, even if its just links to a few websites with good
info, it seems theyre hard to find for ms access.

id like to start off by saying that im running ms access 2003, and im
trying to add some new functions to an existing project. The existing
project is a customer database/form which lets you search for customers
based on various criteria. I have one question in regards to the
original project, is there a function i can use to change the current
tab focus? ive got a search tab, and a customer info tab, id like it so
after a search the page moves over to the customers info automaticly,
rather then just simply filtering it.

This isnt the actual problem though, i'll get to that right now....The
new tab on the form is now a sales form id like to tie with a customer.
We offer engines that are available in different styles and
displacements. depending on what style of engine you pick, not all
displacements are available. im using this code to hide
checkboxes(theyre in option groups)

#################################
Private Sub Etype_AfterUpdate()
If Me.Etype.Value = 4 Then
Check262.Visible = False
Check264.Visible = False
Check266.Visible = False
Check268.Visible = False
Check270.Visible = False
Check274.Visible = False
Else
Check262.Visible = True
Check264.Visible = True
Check266.Visible = True
Check268.Visible = True
Check270.Visible = True
Check274.Visible = True
End If
End Sub
#################################
where Etype is the first option group, and the checkboxes are in the
next one. This code works fine, but by doing something like
#################################
Private Sub Etype_AfterUpdate()
If Me.Etype.Value = 4 Then
Check262.Visible = False
Check264.Visible = False
Check266.Visible = False
Check268.Visible = False
Check270.Visible = False
Check274.Visible = False
Else
Check262.Visible = True
Check264.Visible = True
Check266.Visible = True
Check268.Visible = True
Check270.Visible = True
Check274.Visible = True
End If
If Me.Etype.Value = 3 Then
Check262.Visible = False
Check264.Visible = False
Check266.Visible = False
Check268.Visible = False
Check270.Visible = False
Check274.Visible = False
Else
Check262.Visible = True
Check264.Visible = True
Check266.Visible = True
Check268.Visible = True
Check270.Visible = True
Check274.Visible = True
End If
End Sub
######################

I dont get even the first function to work, let alone the others. I'm
not the greatest coder, but im fairly confident this should be simple,
and i wonder why im struggling so much with it.

The last thing i'd like to have in this program are dollar amounts tied
to the different options (engine1=$5000 , displacement4=$1400,
finish3=$200) and have these added up as theyre checked.
Can anyone give me a hand with this? it seems like it should be simple
stuff, but maybe im just going about it all wrong? Thanks for any help
in advance
 
C

cmirra

well, it looks like i solved part of the problem by using "elseif"
rather then trying "else if". I still need some suggestions on what to
do for the adding of prices based on the checkmarks.

TIA
 
G

Guest

based on various criteria. I have one question in regards to the
original project, is there a function i can use to change the current
tab focus? ive got a search tab, and a customer info tab, id like it so
after a search the page moves over to the customers info automaticly,
rather then just simply filtering it.

If you have a tab control named "TabCtl4" with four tabs, the tabs can be
referenced by the tab index number. The tabs are zero based, so they are
numbered 0 - 3.

To set the focus to the 3rd tab, you would use

Me.TabCtl4.Pages(2).SetFocus

This isnt the actual problem though, i'll get to that right now....The
new tab on the form is now a sales form id like to tie with a customer.
We offer engines that are available in different styles and
displacements. depending on what style of engine you pick, not all
displacements are available. im using this code to hide
checkboxes(theyre in option groups)

#################################
Private Sub Etype_AfterUpdate()
If Me.Etype.Value = 4 Then
Check262.Visible = False
Check264.Visible = False
Check266.Visible = False
Check268.Visible = False
*** said:
I dont get even the first function to work, let alone the others. I'm
not the greatest coder, but im fairly confident this should be simple,
and i wonder why im struggling so much with it.

What are you going to do when the options, prices, models, etc. change?? It
sounds like you are going to have to change the oprion groups and all the
code.
I would be using Cascading Combo Boxes. I once had 9 Cascading Combo Boxes.
I also made a page using 9 list boxes to see all the options as I selected
an item in the list box. I guess it would be called Cascading List Boxes.
Worked great!

The last thing i'd like to have in this program are dollar amounts tied
to the different options (engine1=$5000 , displacement4=$1400,
finish3=$200) and have these added up as theyre checked.
Can anyone give me a hand with this? it seems like it should be simple
stuff, but maybe im just going about it all wrong? Thanks for any help
in advance

Using Option groups, you will have to write more code to determine the
prices for the different selected options. If you hard code the prices, then
you will have to edit the code whenever the prices change. If you store the
prices in tables, then you might use a lot of DLOOKUP() functions. Not
knowing the number of option groups or prices, I can't provide any code.


If you used Cascading Combo Boxes, the combo box ROW SOURCE query could have
multiple columns, one of which could be the price. Then it would be easy to
add the combo boxes using the .Column() property to get the price.

If the tables had a boolean column (maybe named "Active"), you could set
options "inactive" to remove them from the query results set but still keep
them in the table. A form for maintenance (Add/Edit/Set Inactive) - a lot
easier than always editing the forms and code.

HTH
 
C

cmirra

Thanks for the reply Steve, i was begining to lose hope of getting any
help over here :) I'd rather not use the comboboxes as ive already got
all the code for the checkboxes coded, that part of my problem is all
done, and now that ive got the code to change the tab(using it in the
project will have to wait until monday when im back at the office), the
only problem now will be setting the prices. Im guessing i can just
stick a variable into my code at the end of the checkbox disable
funtion with the dollar value then use some code to add them up?
hopefully ill get this figured out, but its actually comming together
which is a relief :) thanks for the input
 
G

Guest

Thanks for the reply Steve, i was begining to lose hope of getting any
help over here :) I'd rather not use the comboboxes as ive already got
all the code for the checkboxes coded, that part of my problem is all
done, and now that ive got the code to change the tab(using it in the
project will have to wait until monday when im back at the office), the
only problem now will be setting the prices. Im guessing i can just
stick a variable into my code at the end of the checkbox disable
funtion with the dollar value then use some code to add them up?
hopefully ill get this figured out, but its actually comming together
which is a relief :) thanks for the input

I had to do some thinking about your questions. I knew the focus could be
set to a tab (I once saw a question about it in the NG but forgot the group
it was in), so I put together a form to test it.

I still think the list/combo boxes are the way to go here - a lot less code
headaches. The combo box would have the price in one of the row source
columns. All that would be required would be a text box to add the combo
boxes prices.


Some thoughts on how to use your code to get the prices......

You could use global variables or text boxes on the form with the visible
property set to FALSE.

Lets use your example in your first post:
to the different options (engine1=$5000 , displacement4=$1400,
finish3=$200) and have these added up as theyre checked

Lets say there are two options for engines:
Small block - $5000 (engine1)
Large Block - $6500 (engine2)

For displacement, the small block has:
283 ci - $ 600
327 ci - $1000
350 ci - $1400
(the 305 is gutless - $0)

and the Large block:
396 ci - $1400
427 ci - $2000

Each of the accessories on the engines can be painted, chromed or powder
coated. I'm not going to list the 3 prices for the finish for each of the
displacements.... you get the idea.. :)

painted - $200
chromed - $ 600
powder coated - $ 1000

So, using variables -

Create three global variables:

g_engine, g_displacement and g_finish

In your code, you would set the variable to the associated price. I you pick
engine1 then g_engine = 5000; if you pick engine2 then g_engine = 6500. Same
with the other two options.

When you select a different engine, you have to set all other global
variables to 0. If you select a different displacement, then the global
variable for the finish needs to be set to 0.

After each selection that has a price, you could total the global varaibles
and put the total in a text box on the form.


Using text boxes -

Same idea as global variables, but using text boxes on the form that have
the visible property set to FALSE. The control source for the "txtTotal" text
box would be

= txtEngine + txtDisplacement + txtFinish

(if the text boxes were names as above)


To recalculate the total, somewhere you could put

Me.txtTotal.Refresh (or maybe .Requery)

Sorry this is so long.... hope one of these will help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top