423,319 Members | 2,663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,319 IT Pros & Developers. It's quick & easy.

Open a Form based on a combo box result.

P: 4
I've been wrestling with what is probaly silly to most. I created a combo box that lists numbers 1-7 (Days of week). I want to open the corresponding form based on the drop down result.
this is the code i used in the 'after update' code...i keep getting compile errors...I'm probably not holding my lips right, but i've exhausted my limited knowledge.

any Help is greatly appreciated.
Warmest regards
Oct 8 '17 #1
Share this Question
Share on Google+
5 Replies

Expert 100+
P: 1,291
It looks as if all the Psychic advisers are on holiday, Bob.

How on earth do you expect an answer to this question with no more information than something does not work?

Oct 9 '17 #2

P: 4
Phil, thanks for the quick reply...the code never made it...here what it looks like ...I think.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cbxTrainingDay_AfterUpdate()
  2. DoCmd.OpenForm "frmDay1Input", “Day= "1" & Me.MyCombo
  3. DoCmd.OpenForm "frmDay2Input",,,"Day= "2" & Me.MyCombo
  4. DoCmd.OpenForm "frmDay3Input",,,"Day= "3" & Me.MyCombo
  5. DoCmd.OpenForm "frmDay4Input",,,"Day= "4" & Me.MyCombo
  6. DoCmd.OpenForm "frmDay5Input",,,"Day= "5" & Me.MyCombo
  7. DoCmd.OpenForm "frmDay6Input",,,"Day= "6" & Me.MyCombo
  8. DoCmd.OpenForm "frmDay7Input",,,"Day= "7" & Me.MyCombo
  10. DoCmd.SetWarnings True
  11. End Sub
The other issue I have is when i run an update query, it shows that the records are updated, but when i look at the table, the fields selected are empty...here is the code for the query:

Update query for tblWODDate:
Expand|Select|Wrap|Line Numbers
  1. UPDATE TblMovements INNER JOIN TblTempInput1 ON TblMovements.Movements = TblTempInput1.Movements SET TblTempInput1.MovementGroup = [TblMovements]![MovementGroup], TblTempInput1.[Group] = [TblMovements]![Group], TblTempInput1.[Day] = 1
Any help is hugely appreciated.
Best Regards,
Oct 10 '17 #3

Expert 100+
P: 1,291
We'll look at one problem at a time

I am assuming that your combo box is called CbxTrainingDay. If so what is the control called MyCombo? I presume this is where you are getting your compile error as my guess is there is no such control.

Now your current code is using a WHERE condition. I much prefere something like
Expand|Select|Wrap|Line Numbers
  1.     Dim WHEREClause as String
  3.     WHEREClause = "XXXXXXXXX"
  4.     DoCmd.OpenForm FormName, , , WHEREClause
That way, you can evaluate in the Debug window, the value of the WHEREClause.

Next question have all the forms different layouts and data. If not why do you have 7 separate forms. I suspect your data isn't normalised, so we better have a look at your table structure. The best way to do this is to include an image of your relationship window with the tables fully expanded in your reply.

Oct 10 '17 #4

P: 4
I've attached the tbleTempInput and Relationship screen shot. Thanks again for all of your help.

Best Regards,
Bob Varga
US Army(Retired)
Attached Files
File Type: docx Relationship screen.docx (341.8 KB, 79 views)
File Type: docx tblTempInput1 Design View.docx (894.0 KB, 64 views)
Oct 14 '17 #5

Expert 100+
P: 1,291
Thank Bob.

Think we need to get back to first principals as, I hope you don't mind me saying, your relationships do not look at all clever.

So what is the Db supposed to to - what do you want to enter & what do you want to get out?

A very quick thought is that whatever you are trying to achieve, it looks as if there should only be one form based on a single input table, and that form is FILTERED by the day you want to display. I need a lot more information before I (hopefully) can be of more help

Oct 14 '17 #6

Post your reply

Sign in to post your reply or Sign up for a free account.