422,757 Members | 1,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,757 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
BobV
Oct 8 '17 #1
Share this Question
Share on Google+
5 Replies


PhilOfWalton
Expert 100+
P: 1,116
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?


Phil
Oct 9 '17 #2

P: 4
Phil, thanks for the quick reply...the code never made it...here what it looks like ...I think.

Private Sub cbxTrainingDay_AfterUpdate()
DoCmd.OpenForm "frmDay1Input", “Day= "1" & Me.MyCombo
DoCmd.OpenForm "frmDay2Input",,,"Day= "2" & Me.MyCombo
DoCmd.OpenForm "frmDay3Input",,,"Day= "3" & Me.MyCombo
DoCmd.OpenForm "frmDay4Input",,,"Day= "4" & Me.MyCombo
DoCmd.OpenForm "frmDay5Input",,,"Day= "5" & Me.MyCombo
DoCmd.OpenForm "frmDay6Input",,,"Day= "6" & Me.MyCombo
DoCmd.OpenForm "frmDay7Input",,,"Day= "7" & Me.MyCombo

DoCmd.SetWarnings True
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:
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,
Bob
Oct 10 '17 #3

PhilOfWalton
Expert 100+
P: 1,116
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
  2.  
  3.     WHEREClause = "XXXXXXXXX"
  4.     DoCmd.OpenForm FormName, , , WHEREClause
  5.  
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.

Phil
Oct 10 '17 #4

P: 4
Phil,
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, 60 views)
File Type: docx tblTempInput1 Design View.docx (894.0 KB, 46 views)
Oct 14 '17 #5

PhilOfWalton
Expert 100+
P: 1,116
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

Phil
Oct 14 '17 #6

Post your reply

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