Solved Combobox in a child form (1 Viewer)

silversun

Registered User.
Local time
Yesterday, 16:59
Joined
Dec 28, 2012
Messages
204
Hi All,
I hope you all are very well.

I have a data entry form created by MS Access 2016.

I want to have a combobox that lists different items based on selction of cmb_items (like a castcaded combobox in a countinues subform). I name it cmb_packages and it gets its values from T_packages, column(1). When user selects any of the items in cmb_packages I need to have a textbox to show a short message that is again in the same table T_packages.Column(3) labeled as "msg".
I was able to setup castcaded comboboxes with the VBA's but I was stucked in this last part to show the message. :unsure:
Please see my attached db and help me if you can.
Have a nice day
Masoud
 

Attachments

  • Database5-simple version.accdb
    1.7 MB · Views: 283

June7

AWF VIP
Local time
Yesterday, 15:59
Joined
Mar 9, 2014
Messages
5,488
Expression in textbox ControlSource: =[cmb_packages].[column](3)
 

mike60smart

Registered User.
Local time
Today, 00:59
Joined
Aug 6, 2017
Messages
1,913
Hi All,
I hope you all are very well.

I have a data entry form created by MS Access 2016.

I want to have a combobox that lists different items based on selction of cmb_items (like a castcaded combobox in a countinues subform). I name it cmb_packages and it gets its values from T_packages, column(1). When user selects any of the items in cmb_packages I need to have a textbox to show a short message that is again in the same table T_packages.Column(3) labeled as "msg".
I was able to setup castcaded comboboxes with the VBA's but I was stucked in this last part to show the message. :unsure:
Please see my attached db and help me if you can.
Have a nice day
Masoud
Hi Masoud

See the modified attached db
 

Attachments

  • Database5-simple version.zip
    352.1 KB · Views: 258

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 19:59
Joined
Feb 19, 2002
Messages
43,352
combo 3 raises an error. There seems to be a typo in a control name.
 

mike60smart

Registered User.
Local time
Today, 00:59
Joined
Aug 6, 2017
Messages
1,913
combo 3 raises an error. There seems to be a typo in a control name.
Hi Pat
Don't know how I managed that but here with the corrected version
 

Attachments

  • Database5-simple version.zip
    362.7 KB · Views: 252

mike60smart

Registered User.
Local time
Today, 00:59
Joined
Aug 6, 2017
Messages
1,913
I did not get error.

Did you see post #2?
Hi June

My updated Db was based on your suggesting in Post 2

It did have an error which Pat pointed out and now corrected.
 

silversun

Registered User.
Local time
Yesterday, 16:59
Joined
Dec 28, 2012
Messages
204
Hi everyone. Sorry for beeing late.
I was busy with some other stuff.
I downloaded both db's you've attached but unfortunately none of them worked.
I used "=[cmb_packages].[column](3)" in my textbox's control source and nothing was showing up in the textbox when I selected any item from packages combobox.
Any idea?
I appreciate your time
 

Attachments

  • no message shown.jpg
    no message shown.jpg
    50 KB · Views: 239

June7

AWF VIP
Local time
Yesterday, 15:59
Joined
Mar 9, 2014
Messages
5,488
I put that expression in textbox of your original posted db and it works just fine.
 

mike60smart

Registered User.
Local time
Today, 00:59
Joined
Aug 6, 2017
Messages
1,913
Hi
This version does work

The Column Count on the Combobox needed to be changed from 3 to 4
 

Attachments

  • Database5 Working.zip
    331.6 KB · Views: 242
Last edited:

silversun

Registered User.
Local time
Yesterday, 16:59
Joined
Dec 28, 2012
Messages
204
Hi
This version does work

The Column Count on the Combobox needed to be changed from 3 to 4
I used this version and as soon as I select Apple in items combobox it gives me error and shows the VBA code. Once I clear the error message and select other parameters, Units and Packagin, I still don't see the message I was expecting to be appeared in textbox.
I've already changed the column number to 4.
I couldn't solve this issue.
Can you please try it one more time?
Please see the attachments.
Thanks
 

Attachments

  • apple selected.JPG
    apple selected.JPG
    35.4 KB · Views: 210
  • error is shown.jpg
    error is shown.jpg
    105.1 KB · Views: 222
  • no message shown 2.JPG
    no message shown 2.JPG
    37.2 KB · Views: 205
Last edited:

June7

AWF VIP
Local time
Yesterday, 15:59
Joined
Mar 9, 2014
Messages
5,488
Error is with line
Me.cbopackages.RowSource = pSource

There is no control named cbopackages - drop the s at end.

Message will not display in textbox until selection in cboPackage.
 

silversun

Registered User.
Local time
Yesterday, 16:59
Joined
Dec 28, 2012
Messages
204
Error is with line
Me.cbopackages.RowSource = pSource

There is no control named cbopackages - drop the s at end.

Message will not display in textbox until selection in cboPackage.
I did remove the "s" and error was gone. The message is still not showing.

I am going to respond tomorrow if you send me the solution.
Thanks for your time

Its bed time :sleep:
Good night
 

Attachments

  • no message shown 3.JPG
    no message shown 3.JPG
    43.5 KB · Views: 232
Last edited:

June7

AWF VIP
Local time
Yesterday, 15:59
Joined
Mar 9, 2014
Messages
5,488
The cmb_Item combobox code is setting cboPackage with a RowSource that does not include msg field. Fix the code.
Code:
pSource = "SELECT package_ID, package, package_tier, msg " & _
          "FROM T_packages " & _
          "WHERE package_tier = " & Me.cmb_items.Column(2)

Really should be more consistent with prefixes used in object naming.
 

mike60smart

Registered User.
Local time
Today, 00:59
Joined
Aug 6, 2017
Messages
1,913
This is easier
 

Attachments

  • Working.accdb
    1.5 MB · Views: 213

silversun

Registered User.
Local time
Yesterday, 16:59
Joined
Dec 28, 2012
Messages
204
Really should be more consistent with prefixes used in object naming
I used cmb_ for my comboboxes where as friends in here use cbo. I will try to use cbo from now on.
 

silversun

Registered User.
Local time
Yesterday, 16:59
Joined
Dec 28, 2012
Messages
204
The cmb_Item combobox code is setting cboPackage with a RowSource that does not include msg field. Fix the code.
Code:
pSource = "SELECT package_ID, package, package_tier, msg " & _
          "FROM T_packages " & _
          "WHERE package_tier = " & Me.cmb_items.Column(2)

Really should be more consistent with prefixes used in object naming.
I used your solution and it works now.
Thank you
 

silversun

Registered User.
Local time
Yesterday, 16:59
Joined
Dec 28, 2012
Messages
204
This is easier
Thi solution works fine and shows the messages but the problem is why I don't see correct units in my combobox cmb_units? When I select a liquid (water) I'm expecting the voluum units to be listed in my combobox. Please see the attachment.
 

Attachments

  • wrong units.JPG
    wrong units.JPG
    20.8 KB · Views: 161

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 19:59
Joined
Feb 19, 2002
Messages
43,352
I'm expecting the voluum units to be listed in my combobox
I didn't look at the database so I'm not sure what that means. If it means you want to see the quantity when the units is not Each (or whatever you use), you would change the RowSource query of the combo to concatenate the two fields.
 

mike60smart

Registered User.
Local time
Today, 00:59
Joined
Aug 6, 2017
Messages
1,913
Thi solution works fine and shows the messages but the problem is why I don't see correct units in my combobox cmb_units? When I select a liquid (water) I'm expecting the voluum units to be listed in my combobox. Please see the attachment.
Can you upload your latest version
 

silversun

Registered User.
Local time
Yesterday, 16:59
Joined
Dec 28, 2012
Messages
204
Can you upload your latest version
Here is the version that shows units improperly when I select water. I need to see voluume units when water is selected.
DB is attached with your solution.
 

Attachments

  • Working (1)mike.accdb
    1.2 MB · Views: 212

Users who are viewing this thread

Top Bottom