Checkbox to activate Combo box to then populate textbox - Possible at all? Pls Help (1 Viewer)

plantgeek

New member
Local time
Yesterday, 21:47
Joined
Sep 10, 2019
Messages
9
Hello there,

First off, this is my first post (aside from the introductions page) and I could use some guidance.
I am new to vba coding and have no idea what I am doing.
I am working on a costing db and am trying to add an exchange rate option to a costing form.

The Goal:
Is to have a checkbox entitled "Exchange" to select whether the user will be applying an exchange rate.

Next, if the user clicks on the checkbox, it activates a combo box that offers a "USD to CAN" or "CAN to USD" exchange option (These exchange options are being pulled from an exchange rate table).

When an exchange rate is selected from the Combo box , it should populate the text box with the corresponding exchange rate.

I have included a sample zip file of the exchange rate table along with the form with the three elements, but I cannot figure out how to get them to work in the order I want and how to get the exchange rate to populate the text box.

I would like to learn where to start and what best practice is. Please bear in mind I am a complete newb. I appreciate any help or insights on where I can begin to tackle this.

Please let me know if you have any questions.
 

Attachments

plantgeek

New member
Local time
Yesterday, 21:47
Joined
Sep 10, 2019
Messages
9
I appreciate your time - thank you.

What I am trying to do is ensure that the user is able to click on the exchange option check box and populate the exchange (which is what it is currently doing), but if they decide to change it they can opt to click off. When I try to click the box after the initial click, it unfortunately will not allow me to edit the check box.

I apologize if I didn't state that when I should have. :(
 

arnelgp

error reading drive A:
Local time
Today, 09:47
Joined
May 7, 2009
Messages
9,286
the checkbox is in Triple state, that is why you cannot edit it.
(see checkbox's property->data->triple state). I already set it to No.
 

Attachments

plantgeek

New member
Local time
Yesterday, 21:47
Joined
Sep 10, 2019
Messages
9
Hello arnelgp, thank you. Sorry for the delay, it has been crazy these past couple of days at work and have not had an opportunity to pop back in here.

First off, thank you for taking the time to help me, I do appreciate it.

Unfortunately, when I click the check box to activate the exchange cbo box, the cbo box is deactivated (grayed out).

What I would like is to understand where I am going wrong in my first application.

Second, this sample was only to show what I'd like to do, but will be adding this function to a larger costing database that currently needs the exchange rate option.

Would you be able to guide me to help me understand what I am doing wrong in my sample?
 

arnelgp

error reading drive A:
Local time
Today, 09:47
Joined
May 7, 2009
Messages
9,286
are you referring to the one I upload?
I just tested it, if checked combo is activated.
if unchecked, deactivated.

on design view of your form, click on the checkbox.
on it's property sheet->Data->triple state: No.
 

plantgeek

New member
Local time
Yesterday, 21:47
Joined
Sep 10, 2019
Messages
9
Hello arnelgp, I apologize! I had the previous sample and hadn't downloaded the new one. Thank you for your help I will check out the code to see how you have handled this.

I appreciate your help!:)
 

arnelgp

error reading drive A:
Local time
Today, 09:47
Joined
May 7, 2009
Messages
9,286
goodluck and comeback anytime!
 

Mark_

Longboard on the internet
Local time
Yesterday, 18:47
Joined
Sep 12, 2017
Messages
2,112
From a design standpoint, I'll admit I'd do this a little differently.

I'd have your combo for exchange rates. I'd have the default for it be "", and "" would be an option. Then if you DON'T have a value in the combo, you know your NOT using an exchange rate. Otherwise you know which one you are using. This means your not using two different fields to store the same data.

In all cases where you'd need to use the exchange rate, you'd be looking at the value you've selected in the combo box, so you'd never be looking for the check box. In all cases where you won't use an exchange rate, you'd be looking at the value in teh combo box to be "", so you'd never be looking at the check box.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 21:47
Joined
Feb 19, 2002
Messages
28,755
Just FYI - "" is a ZLS (Zero Length STRING) and is ONLY valid for text fields. If the combo is bound to a numeric field, "" would be invalid.
 

Micron

AWF VIP
Local time
Yesterday, 21:47
Joined
Oct 20, 2018
Messages
2,707
My first thought as I read was also to do away with the checkbox as it just adds an unnecessary layer of complexity, so nice call, Mark. Perhaps the only difference is that I was thinking of (none) as the first combo option for exchange rates. However, text is not an invalid value for a combo bound to a numeric field because the text field would be the 2nd column, not the bound column.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 21:47
Joined
Feb 19, 2002
Messages
28,755
"None" is a much better choice. Having the combo be empty just looks like nothing was chosen but maybe it should have been.
 

plantgeek

New member
Local time
Yesterday, 21:47
Joined
Sep 10, 2019
Messages
9
Again, I am sorry for the delay. I do appreciate all your feedback! There is so much I don't know yet in terms of thinking about complexity, memory limits etc, and as I keep going I find I encounter different problems that I have to figure out lol.
I have since gone with the drop down and the exchange is working well with the costing database I have on the go.
I will certainly, take these other suggestions and keep them in mind for future applications.
 

plantgeek

New member
Local time
Yesterday, 21:47
Joined
Sep 10, 2019
Messages
9
Thank you

Again, I am sorry for the delay. I do appreciate all your feedback! There is so much I don't know yet in terms of thinking about complexity, memory limits etc, and as I keep going I find I encounter different problems that I have to figure out lol.
I have since gone with the drop down and the exchange is working well with the costing database I have on the go.
I will certainly, take these other suggestions and keep them in mind for future applications.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom