Results 1 to 3 of 3
  1. #1
    El Rebelde is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2011
    Posts
    2

    Setting default values based on a variable value

    Hello everyone. I've searched the forum and not found any help with this question:



    I have a form which allows me to input the Subject, Teacher, and Classroom timetabled for each Class for each Period of each Day.

    I would like to avoid as much manual data input as possible, so I'd like to set the Teacher and Classroom values by default to those recorded in a table as soon as I choose the Subject for the Period.

    I know I can't enter a reference to a query in the DefaultValue parameter for the fields concerned, and I suppose I'll need to call some code OnUpdate of the Subject field. Is my hunch correct and does anyone have any examples that I could use to amend to my purposes?

    Many thanks in anticipation of your replies.

    Stuart

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    You are going to have a combo box for your Subject. Make this combobox include the Teacher and Classroom. Whether or not these additional columns are visible to the user is your decision. But they need to be part of the combobox.

    In the AfterUpdate event of the combobox - you push these values into the other text boxes:

    Me.Teacher=Me.SubjectCombo.column(2)
    Me.Class=Me.SubjectCombo.column(3)

    note that the column count value begins with 0; also if you have a key field in your Subject table and are binding that -vs- instead using the actual text of the subject name with no key field - these decisions will define how many columns you have.....

    hope it helps.

  3. #3
    El Rebelde is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2011
    Posts
    2
    Many thanks, I'm sure that'll do the job. I have the combo box already, as you'd expect, so I just need to draw across the extra columns from the default table and try it out.

    Just finished a 14-hour shift, at 23:30 here in UK and I've just opened a bottle of 'Dorset Nectar' cider. The first toast is to you, NTC; "Good Health!"

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Setting Temporary Variable
    By KEVWB in forum Access
    Replies: 1
    Last Post: 02-07-2011, 01:41 PM
  2. Form Field Default Setting
    By roofbid in forum Programming
    Replies: 3
    Last Post: 12-17-2010, 10:53 AM
  3. Replies: 1
    Last Post: 11-01-2010, 06:59 PM
  4. Setting the Default Value and Proper Case Example
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-27-2010, 07:43 PM
  5. Setting default values in columns
    By crownedzero in forum Programming
    Replies: 0
    Last Post: 06-17-2009, 06:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums